diff options
author | Bartek IwaĆczuk <biwanczuk@gmail.com> | 2023-05-19 02:59:23 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-19 02:59:23 +0200 |
commit | 5b0752234993ee69e47c32db478d2a296f73f396 (patch) | |
tree | 6501e364a82d6ff98845d87fe38744bda7fd1a70 /cli/tsc | |
parent | 8724ba9d084127147e2bb2c997a6bf2f38c9b3d2 (diff) |
BREAKING(unstable): change return type of Deno.serve() API (#19189)
This commit changes the return type of an unstable `Deno.serve()` API
to instead return a `Deno.Server` object that has a `finished` field.
This change is done in preparation to be able to ref/unref the HTTP
server.
Diffstat (limited to 'cli/tsc')
-rw-r--r-- | cli/tsc/dts/lib.deno.unstable.d.ts | 37 |
1 files changed, 28 insertions, 9 deletions
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts index 3a4344bd8..c0c0d16ad 100644 --- a/cli/tsc/dts/lib.deno.unstable.d.ts +++ b/cli/tsc/dts/lib.deno.unstable.d.ts @@ -1305,6 +1305,16 @@ declare namespace Deno { /** **UNSTABLE**: New API, yet to be vetted. * + * @category HTTP Server + */ + export interface Server { + /** A promise that resolves once server finishes - eg. when aborted using + * the signal passed to {@linkcode ServeOptions.signal}. + */ + finished: Promise<void>; + } + /** **UNSTABLE**: New API, yet to be vetted. + * * Serves HTTP requests with the given handler. * * You can specify an object with a port and hostname option, which is the @@ -1331,8 +1341,11 @@ declare namespace Deno { * ```ts * const ac = new AbortController(); * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); + * const server = Deno.serve( + * { signal: ac.signal }, + * (_req) => new Response("Hello, world") + * ); + * server.finished.then(() => console.log("Server closed")); * * console.log("Closing server..."); * ac.abort(); @@ -1362,7 +1375,7 @@ declare namespace Deno { * * @category HTTP Server */ - export function serve(handler: ServeHandler): Promise<void>; + export function serve(handler: ServeHandler): Server; /** **UNSTABLE**: New API, yet to be vetted. * * Serves HTTP requests with the given handler. @@ -1391,8 +1404,11 @@ declare namespace Deno { * ```ts * const ac = new AbortController(); * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); + * const server = Deno.serve( + * { signal: ac.signal }, + * (_req) => new Response("Hello, world") + * ); + * server.finished.then(() => console.log("Server closed")); * * console.log("Closing server..."); * ac.abort(); @@ -1425,7 +1441,7 @@ declare namespace Deno { export function serve( options: ServeOptions | ServeTlsOptions, handler: ServeHandler, - ): Promise<void>; + ): Server; /** **UNSTABLE**: New API, yet to be vetted. * * Serves HTTP requests with the given handler. @@ -1454,8 +1470,11 @@ declare namespace Deno { * ```ts * const ac = new AbortController(); * - * Deno.serve({ signal: ac.signal }, (_req) => new Response("Hello, world")) - * .then(() => console.log("Server closed")); + * const server = Deno.serve( + * { signal: ac.signal }, + * (_req) => new Response("Hello, world") + * ); + * server.finished.then(() => console.log("Server closed")); * * console.log("Closing server..."); * ac.abort(); @@ -1487,7 +1506,7 @@ declare namespace Deno { */ export function serve( options: ServeInit & (ServeOptions | ServeTlsOptions), - ): Promise<void>; + ): Server; /** **UNSTABLE**: New API, yet to be vetted. * |