diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2024-08-05 22:19:09 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-08-05 23:19:09 +0200 |
commit | 3e1f98236f2a0d1db331caf0a246660fcd104deb (patch) | |
tree | c577c415a8af27dc1c57cc20020626b202b5fa2c /cli/tsc/dts/lib.deno.ns.d.ts | |
parent | ae8d048b6c6e783a2c14d78d63cb9247374ca09d (diff) |
feat: Add Deno.ServeDefaultExport type (#24879)
Closes https://github.com/denoland/deno/issues/23725
Diffstat (limited to 'cli/tsc/dts/lib.deno.ns.d.ts')
-rw-r--r-- | cli/tsc/dts/lib.deno.ns.d.ts | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts index cbf86eec6..084dc1b76 100644 --- a/cli/tsc/dts/lib.deno.ns.d.ts +++ b/cli/tsc/dts/lib.deno.ns.d.ts @@ -6256,6 +6256,35 @@ declare namespace Deno { info: ServeHandlerInfo, ) => Response | Promise<Response>; + /** Interface that module run with `deno serve` subcommand must conform to. + * + * To ensure your code is type-checked properly, make sure to add `satisfies Deno.ServeDefaultExport` + * to the `export default { ... }` like so: + * + * ```ts + * export default { + * fetch(req) { + * return new Response("Hello world"); + * } + * } satisfies Deno.ServeDefaultExport; + * ``` + * + * @category HTTP Server + */ + export interface ServeDefaultExport { + /** A handler for HTTP requests. Consumes a request and returns a response. + * + * If a handler throws, the server calling the handler will assume the impact + * of the error is isolated to the individual request. It will catch the error + * and if necessary will close the underlying connection. + * + * @category HTTP Server + */ + fetch: ( + request: Request, + ) => Response | Promise<Response>; + } + /** Options which can be set when calling {@linkcode Deno.serve}. * * @category HTTP Server |