Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix APIRoute type #3344

Merged
merged 3 commits into from
May 11, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -508,7 +508,7 @@ Update your code to remove this warning.`);
},
}) as APIContext & Params;

return await handler.call(mod, proxy, request);
return handler.call(mod, proxy, request);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this change anything critical?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, VScode said it wasn't needed.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cool, not blocking, just curious.

}

async function replaceHeadInjection(result: SSRResult, html: string): Promise<string> {
Expand Down