Skip to content

Commit

Permalink
Fix APIRoute type (#3344)
Browse files Browse the repository at this point in the history
* Fix APIRoute type

* Adds a changeset

* Update usage of the two API route signatures
  • Loading branch information
matthewp committed May 11, 2022
1 parent 1a5335e commit 46cd8b9
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
5 changes: 5 additions & 0 deletions .changeset/curly-bees-collect.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'astro': patch
---

Fix for APIRoute type
12 changes: 2 additions & 10 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion packages/astro/src/runtime/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down

0 comments on commit 46cd8b9

Please sign in to comment.