diff options
author | 2023-07-03 03:58:27 -0400 | |
---|---|---|
committer | 2023-07-03 15:58:27 +0800 | |
commit | 19c2d43ea41efdd8741007de0774e7e394f174b0 (patch) | |
tree | 20b6da97bec221c2f255c8fc73cefd9fa9ea9e03 | |
parent | bc9ce779d3c02e7a960a8a79ce2610a96b2afcb7 (diff) | |
download | astro-19c2d43ea41efdd8741007de0774e7e394f174b0.tar.gz astro-19c2d43ea41efdd8741007de0774e7e394f174b0.tar.zst astro-19c2d43ea41efdd8741007de0774e7e394f174b0.zip |
Make APIRoute generic like APIContext (#7521)
-rw-r--r-- | .changeset/grumpy-readers-draw.md | 5 | ||||
-rw-r--r-- | packages/astro/src/@types/astro.ts | 8 |
2 files changed, 9 insertions, 4 deletions
diff --git a/.changeset/grumpy-readers-draw.md b/.changeset/grumpy-readers-draw.md new file mode 100644 index 000000000..32156bc8b --- /dev/null +++ b/.changeset/grumpy-readers-draw.md @@ -0,0 +1,5 @@ +--- +"astro": patch +--- + +Add `Props` generic for `APIRoute` type diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index ef958d2a8..69c0ffed5 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1764,21 +1764,21 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a locals: App.Locals; } -export type Props = Record<string, unknown>; - export interface EndpointOutput { body: Body; encoding?: BufferEncoding; } -export type APIRoute = ( - context: APIContext +export type APIRoute<Props extends Record<string, any> = Record<string, any>> = ( + context: APIContext<Props> ) => EndpointOutput | Response | Promise<EndpointOutput | Response>; export interface EndpointHandler { [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); } +export type Props = Record<string, unknown>; + export interface AstroRenderer { /** Name of the renderer. */ name: string; |