From 19c2d43ea41efdd8741007de0774e7e394f174b0 Mon Sep 17 00:00:00 2001 From: Ken Powers Date: Mon, 3 Jul 2023 03:58:27 -0400 Subject: [PATCH] Make APIRoute generic like APIContext (#7521) --- .changeset/grumpy-readers-draw.md | 5 +++++ packages/astro/src/@types/astro.ts | 8 ++++---- 2 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .changeset/grumpy-readers-draw.md diff --git a/.changeset/grumpy-readers-draw.md b/.changeset/grumpy-readers-draw.md new file mode 100644 index 000000000000..32156bc8b81e --- /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 ef958d2a89e1..69c0ffed585c 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -1764,21 +1764,21 @@ export interface APIContext = Record; - export interface EndpointOutput { body: Body; encoding?: BufferEncoding; } -export type APIRoute = ( - context: APIContext +export type APIRoute = Record> = ( + context: APIContext ) => EndpointOutput | Response | Promise; export interface EndpointHandler { [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); } +export type Props = Record; + export interface AstroRenderer { /** Name of the renderer. */ name: string;