summaryrefslogtreecommitdiff
path: root/cli/tsc
diff options
context:
space:
mode:
Diffstat (limited to 'cli/tsc')
-rw-r--r--cli/tsc/diagnostics.rs6
-rw-r--r--cli/tsc/dts/lib.deno.ns.d.ts197
-rw-r--r--cli/tsc/dts/lib.deno.unstable.d.ts286
3 files changed, 197 insertions, 292 deletions
diff --git a/cli/tsc/diagnostics.rs b/cli/tsc/diagnostics.rs
index 15aadff81..edddb0f6f 100644
--- a/cli/tsc/diagnostics.rs
+++ b/cli/tsc/diagnostics.rs
@@ -22,18 +22,12 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[
"UnixListenOptions",
"connect",
"createHttpClient",
- "kill",
"listen",
"listenDatagram",
"dlopen",
"removeSignalListener",
"shutdown",
"umask",
- "serve",
- "ServeInit",
- "ServeTlsInit",
- "Handler",
- "osUptime",
];
static MSG_MISSING_PROPERTY_DENO: Lazy<Regex> =
diff --git a/cli/tsc/dts/lib.deno.ns.d.ts b/cli/tsc/dts/lib.deno.ns.d.ts
index a80ced189..cba6edb3b 100644
--- a/cli/tsc/dts/lib.deno.ns.d.ts
+++ b/cli/tsc/dts/lib.deno.ns.d.ts
@@ -5668,4 +5668,201 @@ declare namespace Deno {
* @category Runtime Environment
*/
export function gid(): number | null;
+
+ /** Information for a HTTP request.
+ *
+ * @category HTTP Server
+ */
+ export interface ServeHandlerInfo {
+ /** The remote address of the connection. */
+ remoteAddr: Deno.NetAddr;
+ }
+
+ /** 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
+ */
+ export type ServeHandler = (
+ request: Request,
+ info: ServeHandlerInfo,
+ ) => Response | Promise<Response>;
+
+ /** Options which can be set when calling {@linkcode Deno.serve}.
+ *
+ * @category HTTP Server
+ */
+ export interface ServeOptions {
+ /** The port to listen on.
+ *
+ * @default {8000} */
+ port?: number;
+
+ /** A literal IP address or host name that can be resolved to an IP address.
+ *
+ * __Note about `0.0.0.0`__ While listening `0.0.0.0` works on all platforms,
+ * the browsers on Windows don't work with the address `0.0.0.0`.
+ * You should show the message like `server running on localhost:8080` instead of
+ * `server running on 0.0.0.0:8080` if your program supports Windows.
+ *
+ * @default {"0.0.0.0"} */
+ hostname?: string;
+
+ /** An {@linkcode AbortSignal} to close the server and all connections. */
+ signal?: AbortSignal;
+
+ /** Sets `SO_REUSEPORT` on POSIX systems. */
+ reusePort?: boolean;
+
+ /** The handler to invoke when route handlers throw an error. */
+ onError?: (error: unknown) => Response | Promise<Response>;
+
+ /** The callback which is called when the server starts listening. */
+ onListen?: (params: { hostname: string; port: number }) => void;
+ }
+
+ /** Additional options which are used when opening a TLS (HTTPS) server.
+ *
+ * @category HTTP Server
+ */
+ export interface ServeTlsOptions extends ServeOptions {
+ /** Server private key in PEM format */
+ cert: string;
+
+ /** Cert chain in PEM format */
+ key: string;
+ }
+
+ /**
+ * @category HTTP Server
+ */
+ export interface ServeInit {
+ /** The handler to invoke to process each incoming request. */
+ handler: ServeHandler;
+ }
+
+ /** An instance of the server created using `Deno.serve()` API.
+ *
+ * @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>;
+
+ /**
+ * Make the server block the event loop from finishing.
+ *
+ * Note: the server blocks the event loop from finishing by default.
+ * This method is only meaningful after `.unref()` is called.
+ */
+ ref(): void;
+
+ /** Make the server not block the event loop from finishing. */
+ unref(): void;
+ }
+
+ /** Serves HTTP requests with the given handler.
+ *
+ * The below example serves with the port `8000` on hostname `"127.0.0.1"`.
+ *
+ * ```ts
+ * Deno.serve((_req) => new Response("Hello, world"));
+ * ```
+ *
+ * @category HTTP Server
+ */
+ export function serve(handler: ServeHandler): Server;
+ /** Serves HTTP requests with the given option bag and handler.
+ *
+ * You can specify an object with a port and hostname option, which is the
+ * address to listen on. The default is port `8000` on hostname `"127.0.0.1"`.
+ *
+ * You can change the address to listen on using the `hostname` and `port`
+ * options. The below example serves on port `3000` and hostname `"0.0.0.0"`.
+ *
+ * ```ts
+ * Deno.serve(
+ * { port: 3000, hostname: "0.0.0.0" },
+ * (_req) => new Response("Hello, world")
+ * );
+ * ```
+ *
+ * You can stop the server with an {@linkcode AbortSignal}. The abort signal
+ * needs to be passed as the `signal` option in the options bag. The server
+ * aborts when the abort signal is aborted. To wait for the server to close,
+ * await the promise returned from the `Deno.serve` API.
+ *
+ * ```ts
+ * const ac = new AbortController();
+ *
+ * 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();
+ * ```
+ *
+ * By default `Deno.serve` prints the message
+ * `Listening on http://<hostname>:<port>/` on listening. If you like to
+ * change this behavior, you can specify a custom `onListen` callback.
+ *
+ * ```ts
+ * Deno.serve({
+ * onListen({ port, hostname }) {
+ * console.log(`Server started at http://${hostname}:${port}`);
+ * // ... more info specific to your server ..
+ * },
+ * }, (_req) => new Response("Hello, world"));
+ * ```
+ *
+ * To enable TLS you must specify the `key` and `cert` options.
+ *
+ * ```ts
+ * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n";
+ * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n";
+ * Deno.serve({ cert, key }, (_req) => new Response("Hello, world"));
+ * ```
+ *
+ * @category HTTP Server
+ */
+ export function serve(
+ options: ServeOptions | ServeTlsOptions,
+ handler: ServeHandler,
+ ): Server;
+ /** Serves HTTP requests with the given option bag.
+ *
+ * You can specify an object with a port and hostname option, which is the
+ * address to listen on. The default is port `8000` on hostname `"127.0.0.1"`.
+ *
+ * ```ts
+ * const ac = new AbortController();
+ *
+ * const server = Deno.serve({
+ * port: 3000,
+ * hostname: "0.0.0.0",
+ * handler: (_req) => new Response("Hello, world"),
+ * signal: ac.signal,
+ * onListen({ port, hostname }) {
+ * console.log(`Server started at http://${hostname}:${port}`);
+ * },
+ * });
+ * server.finished.then(() => console.log("Server closed"));
+ *
+ * console.log("Closing server...");
+ * ac.abort();
+ * ```
+ *
+ * @category HTTP Server
+ */
+ export function serve(
+ options: ServeInit & (ServeOptions | ServeTlsOptions),
+ ): Server;
}
diff --git a/cli/tsc/dts/lib.deno.unstable.d.ts b/cli/tsc/dts/lib.deno.unstable.d.ts
index bc770dab8..70731fc4e 100644
--- a/cli/tsc/dts/lib.deno.unstable.d.ts
+++ b/cli/tsc/dts/lib.deno.unstable.d.ts
@@ -1252,292 +1252,6 @@ declare namespace Deno {
/** **UNSTABLE**: New API, yet to be vetted.
*
- * Information for a HTTP request.
- *
- * @category HTTP Server
- */
- export interface ServeHandlerInfo {
- /** The remote address of the connection. */
- remoteAddr: Deno.NetAddr;
- }
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
- * 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
- */
- export type ServeHandler = (
- request: Request,
- info: ServeHandlerInfo,
- ) => Response | Promise<Response>;
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
- * Options which can be set when calling {@linkcode Deno.serve}.
- *
- * @category HTTP Server
- */
- export interface ServeOptions extends Partial<Deno.ListenOptions> {
- /** An {@linkcode AbortSignal} to close the server and all connections. */
- signal?: AbortSignal;
-
- /** Sets `SO_REUSEPORT` on POSIX systems. */
- reusePort?: boolean;
-
- /** The handler to invoke when route handlers throw an error. */
- onError?: (error: unknown) => Response | Promise<Response>;
-
- /** The callback which is called when the server starts listening. */
- onListen?: (params: { hostname: string; port: number }) => void;
- }
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
- * Additional options which are used when opening a TLS (HTTPS) server.
- *
- * @category HTTP Server
- */
- export interface ServeTlsOptions extends ServeOptions {
- /** Server private key in PEM format */
- cert: string;
-
- /** Cert chain in PEM format */
- key: string;
- }
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
- * @category HTTP Server
- */
- export interface ServeInit {
- /** The handler to invoke to process each incoming request. */
- handler: ServeHandler;
- }
-
- /** **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>;
-
- /**
- * Make the server block the event loop from finishing.
- *
- * Note: the server blocks the event loop from finishing by default.
- * This method is only meaningful after `.unref()` is called.
- */
- ref(): void;
-
- /** Make the server not block the event loop from finishing. */
- unref(): 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
- * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`.
- *
- * The below example serves with the port `9000`.
- *
- * ```ts
- * Deno.serve((_req) => new Response("Hello, world"));
- * ```
- *
- * You can change the address to listen on using the `hostname` and `port`
- * options. The below example serves on port `3000`.
- *
- * ```ts
- * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world"));
- * ```
- *
- * You can stop the server with an {@linkcode AbortSignal}. The abort signal
- * needs to be passed as the `signal` option in the options bag. The server
- * aborts when the abort signal is aborted. To wait for the server to close,
- * await the promise returned from the `Deno.serve` API.
- *
- * ```ts
- * const ac = new AbortController();
- *
- * 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();
- * ```
- *
- * By default `Deno.serve` prints the message
- * `Listening on http://<hostname>:<port>/` on listening. If you like to
- * change this behavior, you can specify a custom `onListen` callback.
- *
- * ```ts
- * Deno.serve({
- * onListen({ port, hostname }) {
- * console.log(`Server started at http://${hostname}:${port}`);
- * // ... more info specific to your server ..
- * },
- * handler: (_req) => new Response("Hello, world"),
- * });
- * ```
- *
- * To enable TLS you must specify the `key` and `cert` options.
- *
- * ```ts
- * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n";
- * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n";
- * Deno.serve({ cert, key }, (_req) => new Response("Hello, world"));
- * ```
- *
- * @category HTTP Server
- */
- export function serve(handler: ServeHandler): Server;
- /** **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
- * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`.
- *
- * The below example serves with the port `9000`.
- *
- * ```ts
- * Deno.serve((_req) => new Response("Hello, world"));
- * ```
- *
- * You can change the address to listen on using the `hostname` and `port`
- * options. The below example serves on port `3000`.
- *
- * ```ts
- * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world"));
- * ```
- *
- * You can stop the server with an {@linkcode AbortSignal}. The abort signal
- * needs to be passed as the `signal` option in the options bag. The server
- * aborts when the abort signal is aborted. To wait for the server to close,
- * await the promise returned from the `Deno.serve` API.
- *
- * ```ts
- * const ac = new AbortController();
- *
- * 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();
- * ```
- *
- * By default `Deno.serve` prints the message
- * `Listening on http://<hostname>:<port>/` on listening. If you like to
- * change this behavior, you can specify a custom `onListen` callback.
- *
- * ```ts
- * Deno.serve({
- * onListen({ port, hostname }) {
- * console.log(`Server started at http://${hostname}:${port}`);
- * // ... more info specific to your server ..
- * },
- * handler: (_req) => new Response("Hello, world"),
- * });
- * ```
- *
- * To enable TLS you must specify the `key` and `cert` options.
- *
- * ```ts
- * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n";
- * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n";
- * Deno.serve({ cert, key }, (_req) => new Response("Hello, world"));
- * ```
- *
- * @category HTTP Server
- */
- export function serve(
- options: ServeOptions | ServeTlsOptions,
- handler: ServeHandler,
- ): Server;
- /** **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
- * address to listen on. The default is port `9000` on hostname `"127.0.0.1"`.
- *
- * The below example serves with the port `9000`.
- *
- * ```ts
- * Deno.serve((_req) => new Response("Hello, world"));
- * ```
- *
- * You can change the address to listen on using the `hostname` and `port`
- * options. The below example serves on port `3000`.
- *
- * ```ts
- * Deno.serve({ port: 3000 }, (_req) => new Response("Hello, world"));
- * ```
- *
- * You can stop the server with an {@linkcode AbortSignal}. The abort signal
- * needs to be passed as the `signal` option in the options bag. The server
- * aborts when the abort signal is aborted. To wait for the server to close,
- * await the promise returned from the `Deno.serve` API.
- *
- * ```ts
- * const ac = new AbortController();
- *
- * 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();
- * ```
- *
- * By default `Deno.serve` prints the message
- * `Listening on http://<hostname>:<port>/` on listening. If you like to
- * change this behavior, you can specify a custom `onListen` callback.
- *
- * ```ts
- * Deno.serve({
- * onListen({ port, hostname }) {
- * console.log(`Server started at http://${hostname}:${port}`);
- * // ... more info specific to your server ..
- * },
- * handler: (_req) => new Response("Hello, world"),
- * });
- * ```
- *
- * To enable TLS you must specify the `key` and `cert` options.
- *
- * ```ts
- * const cert = "-----BEGIN CERTIFICATE-----\n...\n-----END CERTIFICATE-----\n";
- * const key = "-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n";
- * Deno.serve({ cert, key }, (_req) => new Response("Hello, world"));
- * ```
- *
- * @category HTTP Server
- */
- export function serve(
- options: ServeInit & (ServeOptions | ServeTlsOptions),
- ): Server;
-
- /** **UNSTABLE**: New API, yet to be vetted.
- *
* Allows "hijacking" the connection that the request is associated with. This
* can be used to implement protocols that build on top of HTTP (eg.
* {@linkcode WebSocket}).