mirror of
https://github.com/withastro/astro.git
synced 2024-12-16 21:46:22 -05:00
Make APIRoute generic like APIContext (#7521)
This commit is contained in:
parent
bc9ce779d3
commit
19c2d43ea4
2 changed files with 9 additions and 4 deletions
5
.changeset/grumpy-readers-draw.md
Normal file
5
.changeset/grumpy-readers-draw.md
Normal file
|
@ -0,0 +1,5 @@
|
||||||
|
---
|
||||||
|
"astro": patch
|
||||||
|
---
|
||||||
|
|
||||||
|
Add `Props` generic for `APIRoute` type
|
|
@ -1764,21 +1764,21 @@ export interface APIContext<Props extends Record<string, any> = Record<string, a
|
||||||
locals: App.Locals;
|
locals: App.Locals;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type Props = Record<string, unknown>;
|
|
||||||
|
|
||||||
export interface EndpointOutput {
|
export interface EndpointOutput {
|
||||||
body: Body;
|
body: Body;
|
||||||
encoding?: BufferEncoding;
|
encoding?: BufferEncoding;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type APIRoute = (
|
export type APIRoute<Props extends Record<string, any> = Record<string, any>> = (
|
||||||
context: APIContext
|
context: APIContext<Props>
|
||||||
) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
) => EndpointOutput | Response | Promise<EndpointOutput | Response>;
|
||||||
|
|
||||||
export interface EndpointHandler {
|
export interface EndpointHandler {
|
||||||
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
[method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export type Props = Record<string, unknown>;
|
||||||
|
|
||||||
export interface AstroRenderer {
|
export interface AstroRenderer {
|
||||||
/** Name of the renderer. */
|
/** Name of the renderer. */
|
||||||
name: string;
|
name: string;
|
||||||
|
|
Loading…
Reference in a new issue