summaryrefslogtreecommitdiff
path: root/cli/tsc/dts/lib.deno.ns.d.ts
diff options
context:
space:
mode:
authorBartek IwaƄczuk <biwanczuk@gmail.com>2024-08-05 22:19:09 +0100
committerGitHub <noreply@github.com>2024-08-05 23:19:09 +0200
commit3e1f98236f2a0d1db331caf0a246660fcd104deb (patch)
treec577c415a8af27dc1c57cc20020626b202b5fa2c /cli/tsc/dts/lib.deno.ns.d.ts
parentae8d048b6c6e783a2c14d78d63cb9247374ca09d (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.ts29
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