0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

Fix APIRoute type (#3344)

* Fix APIRoute type

* Adds a changeset

* Update usage of the two API route signatures
This commit is contained in:
Matthew Phillips 2022-05-11 15:07:40 -06:00 committed by GitHub
parent 1a5335ed9a
commit 46cd8b9eb4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 11 deletions

View file

@ -0,0 +1,5 @@
---
'astro': patch
---
Fix for APIRoute type

View file

@ -883,18 +883,10 @@ export interface EndpointOutput<Output extends Body = Body> {
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 {

View file

@ -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<string> {