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; body: Output;
} }
interface APIRoute { export type APIRoute = (context: APIContext) => EndpointOutput | Response;
(context: APIContext): EndpointOutput | Response;
/**
* @deprecated
* Use { context: APIRouteContext } object instead.
*/
(params: Params, request: Request): EndpointOutput | Response;
}
export interface EndpointHandler { export interface EndpointHandler {
[method: string]: APIRoute; [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
} }
export interface AstroRenderer { export interface AstroRenderer {

View file

@ -517,7 +517,7 @@ Update your code to remove this warning.`);
}, },
}) as APIContext & Params; }) 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> { async function replaceHeadInjection(result: SSRResult, html: string): Promise<string> {