fixed APIRoute type (#3365)
* fixed APIRoute type * fixed EndpointHandler type
This commit is contained in:
parent
71af9c8dca
commit
0ead51ae9c
1 changed files with 5 additions and 5 deletions
|
@ -869,8 +869,6 @@ export type Params = Record<string, string | number | undefined>;
|
||||||
|
|
||||||
export type Props = Record<string, unknown>;
|
export type Props = Record<string, unknown>;
|
||||||
|
|
||||||
type Body = string;
|
|
||||||
|
|
||||||
export interface AstroAdapter {
|
export interface AstroAdapter {
|
||||||
name: string;
|
name: string;
|
||||||
serverEntrypoint?: string;
|
serverEntrypoint?: string;
|
||||||
|
@ -878,16 +876,18 @@ export interface AstroAdapter {
|
||||||
args?: any;
|
args?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type Body = string;
|
||||||
|
|
||||||
export interface APIContext {
|
export interface APIContext {
|
||||||
params: Params;
|
params: Params;
|
||||||
request: Request;
|
request: Request;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface EndpointOutput<Output extends Body = Body> {
|
export interface EndpointOutput {
|
||||||
body: Output;
|
body: Body;
|
||||||
}
|
}
|
||||||
|
|
||||||
export type APIRoute = (context: APIContext) => EndpointOutput | Response;
|
export type APIRoute = (context: APIContext) => 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);
|
||||||
|
|
Loading…
Add table
Reference in a new issue