diff --git a/.changeset/curly-bees-collect.md b/.changeset/curly-bees-collect.md new file mode 100644 index 0000000000..982fa253d6 --- /dev/null +++ b/.changeset/curly-bees-collect.md @@ -0,0 +1,5 @@ +--- +'astro': patch +--- + +Fix for APIRoute type diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index e57126180b..050223b53f 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -883,18 +883,10 @@ export interface EndpointOutput { body: Output; } -interface APIRoute { - (context: APIContext): EndpointOutput | Response; - - /** - * @deprecated - * Use { context: APIRouteContext } object instead. - */ - (params: Params, request: Request): EndpointOutput | Response; -} +export type APIRoute = (context: APIContext) => EndpointOutput | Response; export interface EndpointHandler { - [method: string]: APIRoute; + [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); } export interface AstroRenderer { diff --git a/packages/astro/src/runtime/server/index.ts b/packages/astro/src/runtime/server/index.ts index 13d408f978..9a46cb9c73 100644 --- a/packages/astro/src/runtime/server/index.ts +++ b/packages/astro/src/runtime/server/index.ts @@ -517,7 +517,7 @@ Update your code to remove this warning.`); }, }) as APIContext & Params; - return await handler.call(mod, proxy, request); + return handler.call(mod, proxy, request); } async function replaceHeadInjection(result: SSRResult, html: string): Promise {