Skip to content

Commit

Permalink
Make APIRoute generic like APIContext (#7521)
Browse files Browse the repository at this point in the history
  • Loading branch information
knpwrs authored Jul 3, 2023
1 parent bc9ce77 commit 19c2d43
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/grumpy-readers-draw.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Add `Props` generic for `APIRoute` type
8 changes: 4 additions & 4 deletions packages/astro/src/@types/astro.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1764,21 +1764,21 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
locals: App.Locals;
}

export type Props = Record<string, unknown>;

export interface EndpointOutput {
body: Body;
encoding?: BufferEncoding;
}

export type APIRoute = (
context: APIContext
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (
context: APIContext<Props>
) => EndpointOutput | Response | Promise<EndpointOutput | Response>;

export interface EndpointHandler {
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
}

export type Props = Record<string, unknown>;

export interface AstroRenderer {
/** Name of the renderer. */
name: string;
Expand Down

0 comments on commit 19c2d43

Please sign in to comment.