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;
|
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 {
|
||||||
|
|
|
@ -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> {
|
||||||
|
|
Loading…
Reference in a new issue