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:
parent
1a5335ed9a
commit
46cd8b9eb4
3 changed files with 8 additions and 11 deletions
5
.changeset/curly-bees-collect.md
Normal file
5
.changeset/curly-bees-collect.md
Normal file
|
@ -0,0 +1,5 @@
|
|||
---
|
||||
'astro': patch
|
||||
---
|
||||
|
||||
Fix for APIRoute type
|
|
@ -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 {
|
||||
|
|
|
@ -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> {
|
||||
|
|
Loading…
Reference in a new issue