diff options
author | 2022-05-31 20:10:57 +0600 | |
---|---|---|
committer | 2022-05-31 10:10:57 -0400 | |
commit | 0ead51ae9cb98be19e327d2f7caebaec06a8f4a6 (patch) | |
tree | a7635b9b57d3fae5976cd1956107485e1e09a848 | |
parent | 71af9c8dca28e4560d2ce277a03736ebca0c261d (diff) | |
download | astro-0ead51ae9cb98be19e327d2f7caebaec06a8f4a6.tar.gz astro-0ead51ae9cb98be19e327d2f7caebaec06a8f4a6.tar.zst astro-0ead51ae9cb98be19e327d2f7caebaec06a8f4a6.zip |
fixed APIRoute type (#3365)
* fixed APIRoute type
* fixed EndpointHandler type
-rw-r--r-- | packages/astro/src/@types/astro.ts | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/packages/astro/src/@types/astro.ts b/packages/astro/src/@types/astro.ts index dfd85e9b0..6e77ba20c 100644 --- a/packages/astro/src/@types/astro.ts +++ b/packages/astro/src/@types/astro.ts @@ -869,8 +869,6 @@ export type Params = Record<string, string | number | undefined>; export type Props = Record<string, unknown>; -type Body = string; - export interface AstroAdapter { name: string; serverEntrypoint?: string; @@ -878,16 +876,18 @@ export interface AstroAdapter { args?: any; } +type Body = string; + export interface APIContext { params: Params; request: Request; } -export interface EndpointOutput<Output extends Body = Body> { - body: Output; +export interface EndpointOutput { + body: Body; } -export type APIRoute = (context: APIContext) => EndpointOutput | Response; +export type APIRoute = (context: APIContext) => EndpointOutput | Response | Promise<EndpointOutput | Response>; export interface EndpointHandler { [method: string]: APIRoute | ((params: Params, request: Request) => EndpointOutput | Response); |