toiljs 0.0.26 → 0.0.28

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,154 @@
1
+ /**
2
+ * Node-side wire envelope codec for the WASM dev server, byte-for-byte compatible with
3
+ * `server/runtime/envelope.ts` (the ToilScript guest decoder/encoder) and
4
+ * `toil-backend/src/http/envelope.rs` (the production edge).
5
+ *
6
+ * Layout (little-endian, no padding):
7
+ *
8
+ * request:
9
+ * u8 method (0=GET, 1=POST, 2=PUT, 3=DELETE, 4=PATCH, 5=HEAD, 6=OPTIONS)
10
+ * u16 path_len
11
+ * [u8] path
12
+ * u16 n_headers
13
+ * for each header: u16 name_len, u16 val_len, [u8] name, [u8] val
14
+ * u32 body_len
15
+ * [u8] body
16
+ *
17
+ * response: same shape but the first u8+u16 (method + path_len + path)
18
+ * is replaced by `u16 status`.
19
+ *
20
+ * Header names/values and the path must each fit in u16, the body in u32; the
21
+ * encoder throws instead of silently truncating (mirrors `EncodeError` on the
22
+ * edge). The decoder bounds-checks every length field so a malformed guest
23
+ * response can never read past the envelope.
24
+ */
25
+
26
+ /** Method discriminant matching the on-wire envelope byte (part of the wasm ABI; do not reorder). */
27
+ export const METHOD_CODES: Readonly<Record<string, number>> = {
28
+ GET: 0,
29
+ POST: 1,
30
+ PUT: 2,
31
+ DELETE: 3,
32
+ PATCH: 4,
33
+ HEAD: 5,
34
+ OPTIONS: 6,
35
+ };
36
+
37
+ /** A request to serialize for the guest. `path` includes the query string. */
38
+ export interface EnvelopeRequest {
39
+ readonly method: string;
40
+ readonly path: string;
41
+ /** Full request header list, passed through to the guest. */
42
+ readonly headers: readonly (readonly [string, string])[];
43
+ readonly body: Uint8Array;
44
+ }
45
+
46
+ /** The decoded guest response envelope. */
47
+ export interface EnvelopeResponse {
48
+ readonly status: number;
49
+ readonly headers: readonly (readonly [string, string])[];
50
+ readonly body: Uint8Array;
51
+ }
52
+
53
+ const U16_MAX = 0xffff;
54
+ const U32_MAX = 0xffffffff;
55
+
56
+ /**
57
+ * Encode `req` into a fresh buffer. Throws on an unsupported method or a field
58
+ * that does not fit its length prefix; callers turn that into a clean 4xx (or
59
+ * route the request past the guest) instead of handing the guest garbage.
60
+ */
61
+ export function encodeRequestEnvelope(req: EnvelopeRequest): Buffer {
62
+ const method = METHOD_CODES[req.method.toUpperCase()];
63
+ if (method === undefined) throw new Error(`unsupported method: ${req.method}`);
64
+
65
+ const path = Buffer.from(req.path, 'utf8');
66
+ if (path.length > U16_MAX) throw new Error(`path too long: ${String(path.length)} bytes`);
67
+ if (req.headers.length > U16_MAX)
68
+ throw new Error(`too many headers: ${String(req.headers.length)}`);
69
+ if (req.body.length > U32_MAX) throw new Error(`body too long: ${String(req.body.length)} bytes`);
70
+
71
+ const headers: { name: Buffer; value: Buffer }[] = [];
72
+ let headersSize = 0;
73
+ for (const [name, value] of req.headers) {
74
+ const n = Buffer.from(name, 'utf8');
75
+ const v = Buffer.from(value, 'utf8');
76
+ if (n.length > U16_MAX || v.length > U16_MAX)
77
+ throw new Error(`header too long: ${name}`);
78
+ headers.push({ name: n, value: v });
79
+ headersSize += 4 + n.length + v.length;
80
+ }
81
+
82
+ const total = 1 + 2 + path.length + 2 + headersSize + 4 + req.body.length;
83
+ const out = Buffer.allocUnsafe(total);
84
+ let cur = 0;
85
+
86
+ out.writeUInt8(method, cur);
87
+ cur += 1;
88
+ out.writeUInt16LE(path.length, cur);
89
+ cur += 2;
90
+ cur += path.copy(out, cur);
91
+
92
+ out.writeUInt16LE(headers.length, cur);
93
+ cur += 2;
94
+ for (const h of headers) {
95
+ out.writeUInt16LE(h.name.length, cur);
96
+ cur += 2;
97
+ out.writeUInt16LE(h.value.length, cur);
98
+ cur += 2;
99
+ cur += h.name.copy(out, cur);
100
+ cur += h.value.copy(out, cur);
101
+ }
102
+
103
+ out.writeUInt32LE(req.body.length, cur);
104
+ cur += 4;
105
+ cur += Buffer.from(req.body.buffer, req.body.byteOffset, req.body.length).copy(out, cur);
106
+
107
+ return out;
108
+ }
109
+
110
+ /**
111
+ * Decode the response envelope the guest wrote at `bytes`. Throws on
112
+ * truncation or a length field that overruns the envelope (a guest bug);
113
+ * the dispatcher converts that into a 500.
114
+ */
115
+ export function decodeResponseEnvelope(bytes: Uint8Array): EnvelopeResponse {
116
+ const view = Buffer.from(bytes.buffer, bytes.byteOffset, bytes.byteLength);
117
+ let cur = 0;
118
+
119
+ const take = (n: number): number => {
120
+ if (cur + n > view.length)
121
+ throw new Error(`response envelope truncated at byte ${String(cur)}`);
122
+ const at = cur;
123
+ cur += n;
124
+ return at;
125
+ };
126
+
127
+ const status = view.readUInt16LE(take(2));
128
+ if (status === 0) throw new Error('response envelope has status 0');
129
+
130
+ const nHeaders = view.readUInt16LE(take(2));
131
+ const headers: (readonly [string, string])[] = [];
132
+ for (let i = 0; i < nHeaders; i++) {
133
+ const nameLen = view.readUInt16LE(take(2));
134
+ const valLen = view.readUInt16LE(take(2));
135
+ const name = view.toString('utf8', take(nameLen), cur);
136
+ const value = view.toString('utf8', take(valLen), cur);
137
+ headers.push([name, value]);
138
+ }
139
+
140
+ const bodyLen = view.readUInt32LE(take(4));
141
+ const bodyStart = take(bodyLen);
142
+ // Copy out of the guest's linear memory so the response outlives the instance.
143
+ const body = Uint8Array.prototype.slice.call(view, bodyStart, cur);
144
+
145
+ return { status, headers, body };
146
+ }
147
+
148
+ /** Unpack the i64 `handle()` returns: high 32 bits = response offset, low 32 bits = byte length. */
149
+ export function unpackHandleResult(packed: bigint): { ptr: number; len: number } {
150
+ return {
151
+ ptr: Number((packed >> 32n) & 0xffffffffn),
152
+ len: Number(packed & 0xffffffffn),
153
+ };
154
+ }
@@ -0,0 +1,145 @@
1
+ /**
2
+ * The host import surface the dev server exposes to the guest, mirroring the
3
+ * functions the production edge (`toil-backend/src/wasm/host/imports.rs`)
4
+ * registers under the `env` namespace:
5
+ *
6
+ * - `abort(msg, file, line, col)` ToilScript panic hook; raises a trap
7
+ * - `set_status(code)` imperative status (clamped to [100, 599])
8
+ * - `set_header(nPtr, nLen, vPtr, vLen)` imperative response header
9
+ * - `respond_file(pathPtr, pathLen)` stream a file as the response body
10
+ * - `thread_spawn(startArg)` fail-closed stub, always -1 (no threading in dev)
11
+ *
12
+ * The ToilScript runtime returns status + headers in-band via the response
13
+ * envelope, so a toiljs guest today only imports `abort`; the imperative
14
+ * functions are provided for parity with the edge and apply on top of the
15
+ * envelope (a `set_status` wins over the envelope status, `set_header` values
16
+ * are appended). Extra keys in the import object are ignored by
17
+ * `WebAssembly.Instance`, so offering the full surface costs nothing.
18
+ */
19
+
20
+ import { buildCryptoImports, freshCryptoState, type CryptoState } from './crypto.js';
21
+
22
+ /** Limits identical to the edge's `set_header` / `respond_file` bounds. */
23
+ const MAX_TOTAL_HEADERS_BYTES = 64 * 1024;
24
+ const MAX_HEADER_NAME_LEN = 256;
25
+ const MAX_HEADER_VALUE_LEN = 8192;
26
+ const MAX_PATH_LEN = 4096;
27
+
28
+ /** RFC 9110 tchar token, the only bytes allowed in a header name. */
29
+ const TCHAR = /^[!#$%&'*+\-.^_`|~0-9A-Za-z]+$/;
30
+
31
+ /** A guest `abort()` (ToilScript assert/bounds-check failure), surfaced as a trap. */
32
+ export class WasmAbortError extends Error {
33
+ constructor(message: string, fileName: string, line: number, column: number) {
34
+ super(
35
+ `wasm aborted: ${message || '<no message>'}` +
36
+ (fileName ? ` at ${fileName}:${String(line)}:${String(column)}` : ''),
37
+ );
38
+ this.name = 'WasmAbortError';
39
+ }
40
+ }
41
+
42
+ /** Per-dispatch state the imperative host imports write into. */
43
+ export interface DispatchState {
44
+ /** Status from `set_status`, or `null` when the guest never called it. */
45
+ status: number | null;
46
+ /** Headers accumulated by `set_header`, in call order. */
47
+ headers: [string, string][];
48
+ /** Total header bytes so far (cap: {@link MAX_TOTAL_HEADERS_BYTES}). */
49
+ headerBytes: number;
50
+ /** File path from `respond_file`, or `null`; when set, the envelope body is ignored. */
51
+ sendfile: string | null;
52
+ /** Per-dispatch Web Crypto keystore + result scratch (mirrors the edge). */
53
+ crypto: CryptoState;
54
+ }
55
+
56
+ /** A fresh, zeroed per-dispatch state (the edge resets the same way before each request). */
57
+ export function freshDispatchState(): DispatchState {
58
+ return { status: null, headers: [], headerBytes: 0, sendfile: null, crypto: freshCryptoState() };
59
+ }
60
+
61
+ /**
62
+ * Late-bound memory holder: the import object must exist before the instance
63
+ * (and therefore its exported memory) does, so the host functions read through
64
+ * this indirection. The module loader fills it in right after instantiation.
65
+ */
66
+ export interface MemoryRef {
67
+ memory: WebAssembly.Memory | null;
68
+ }
69
+
70
+ function mem(ref: MemoryRef): Buffer {
71
+ if (!ref.memory) throw new Error('host import called before memory was bound');
72
+ return Buffer.from(ref.memory.buffer);
73
+ }
74
+
75
+ /** Bounds-checked byte read out of guest linear memory. */
76
+ function readBytes(ref: MemoryRef, ptr: number, len: number): Buffer {
77
+ const m = mem(ref);
78
+ if (ptr < 0 || len < 0 || ptr + len > m.length)
79
+ throw new Error(`host import read out of bounds: ptr=${String(ptr)} len=${String(len)}`);
80
+ return m.subarray(ptr, ptr + len);
81
+ }
82
+
83
+ /**
84
+ * Read a ToilScript string (UTF-16LE payload, byte length in the u32 at
85
+ * `ptr - 4`). Used by `abort`, whose pointers reference string objects rather
86
+ * than raw byte ranges. A null pointer yields ''.
87
+ */
88
+ function readGuestString(ref: MemoryRef, ptr: number): string {
89
+ if (ptr === 0) return '';
90
+ const m = mem(ref);
91
+ if (ptr < 4 || ptr > m.length) return '';
92
+ const byteLen = m.readUInt32LE(ptr - 4);
93
+ if (ptr + byteLen > m.length) return '';
94
+ return m.toString('utf16le', ptr, ptr + byteLen);
95
+ }
96
+
97
+ /**
98
+ * Build the `env` import object for one instance. `state` collects what the
99
+ * imperative imports produce during a dispatch; bind a fresh state per request.
100
+ */
101
+ export function buildHostImports(ref: MemoryRef, state: DispatchState): WebAssembly.Imports {
102
+ return {
103
+ env: {
104
+ abort: (msgPtr: number, filePtr: number, line: number, col: number): void => {
105
+ throw new WasmAbortError(
106
+ readGuestString(ref, msgPtr),
107
+ readGuestString(ref, filePtr),
108
+ line,
109
+ col,
110
+ );
111
+ },
112
+
113
+ set_status: (code: number): void => {
114
+ state.status = code >= 100 && code <= 599 ? code : 500;
115
+ },
116
+
117
+ set_header: (namePtr: number, nameLen: number, valPtr: number, valLen: number): void => {
118
+ if (nameLen > MAX_HEADER_NAME_LEN)
119
+ throw new Error(`header name too long: ${String(nameLen)} bytes`);
120
+ if (valLen > MAX_HEADER_VALUE_LEN)
121
+ throw new Error(`header value too long: ${String(valLen)} bytes`);
122
+ if (state.headerBytes + nameLen + valLen > MAX_TOTAL_HEADERS_BYTES)
123
+ throw new Error('total response headers exceed 64 KiB');
124
+ const name = readBytes(ref, namePtr, nameLen).toString('utf8');
125
+ const value = readBytes(ref, valPtr, valLen).toString('utf8');
126
+ if (!TCHAR.test(name)) throw new Error(`invalid header name: ${name}`);
127
+ if (/[\r\n]/.test(value)) throw new Error('header value contains CR/LF');
128
+ state.headers.push([name, value]);
129
+ state.headerBytes += nameLen + valLen;
130
+ },
131
+
132
+ respond_file: (pathPtr: number, pathLen: number): void => {
133
+ if (pathLen > MAX_PATH_LEN)
134
+ throw new Error(`respond_file path too long: ${String(pathLen)} bytes`);
135
+ state.sendfile = readBytes(ref, pathPtr, pathLen).toString('utf8');
136
+ },
137
+
138
+ thread_spawn: (_startArg: number): number => -1,
139
+
140
+ // Web Crypto host functions (`env.crypto.*`), backed by Node's
141
+ // `crypto`. The dev server skips metering, so these charge nothing.
142
+ ...buildCryptoImports(ref, state.crypto),
143
+ },
144
+ };
145
+ }
@@ -0,0 +1,242 @@
1
+ /**
2
+ * The toiljs WASM dev server: a uWebSockets.js front (via @btc-vision/hyper-express,
3
+ * the same stack as `toiljs/backend`) that dispatches HTTP requests into the
4
+ * ToilScript-compiled server wasm exactly like the production edge does, and
5
+ * proxies everything the server does not claim to an internal Vite dev server,
6
+ * so dev keeps 100% of Vite's behavior (HMR, transforms, toolbar endpoints,
7
+ * public assets, SPA fallback).
8
+ *
9
+ * Request flow:
10
+ *
11
+ * browser ── uWS :port ──► wasm `handle()` (fresh instance, envelope ABI)
12
+ * │ │
13
+ * │ └─ "unhandled" marker (no route matched)
14
+ * ▼ │
15
+ * Vite dev server (loopback) ◄──────────────┘
16
+ *
17
+ * Dev intentionally skips the edge's metering, gas, pooling and snapshot-reset
18
+ * machinery; the ABI (envelope layout, `handle(ofs, len) -> i64`, host import
19
+ * surface, trap isolation) is identical so a server that runs here runs there.
20
+ */
21
+
22
+ import fs from 'node:fs';
23
+ import path from 'node:path';
24
+
25
+ import { Server, type Request, type Response } from '@btc-vision/hyper-express';
26
+ import pc from 'picocolors';
27
+
28
+ import { METHOD_CODES, type EnvelopeRequest } from './envelope.js';
29
+ import { WasmServerModule } from './module.js';
30
+ import { proxyToVite, wireWebsocketProxy, type ViteTarget } from './proxy.js';
31
+
32
+ export { METHOD_CODES, encodeRequestEnvelope, decodeResponseEnvelope, unpackHandleResult } from './envelope.js';
33
+ export type { EnvelopeRequest, EnvelopeResponse } from './envelope.js';
34
+ export { WasmServerModule, WasmAbortError, UNHANDLED_HEADER } from './module.js';
35
+ export type { WasmDispatchResult } from './module.js';
36
+ export { buildHostImports, freshDispatchState } from './host.js';
37
+ export type { DispatchState, MemoryRef } from './host.js';
38
+ export type { ViteTarget } from './proxy.js';
39
+
40
+ const DEFAULT_MAX_BODY_LENGTH = 1024 * 1024 * 8;
41
+
42
+ /**
43
+ * Paths that are Vite's own by construction; skipping the wasm round-trip for
44
+ * them keeps the hot path of module serving untouched. Everything else is
45
+ * offered to the server first (it answers or yields via the unhandled marker).
46
+ */
47
+ const VITE_PREFIXES = ['/@', '/node_modules/', '/__toil/'];
48
+
49
+ /** Minimal type map for `respond_file` bodies when the guest set no content-type. */
50
+ const MIME: Readonly<Record<string, string>> = {
51
+ '.html': 'text/html; charset=utf-8',
52
+ '.js': 'text/javascript; charset=utf-8',
53
+ '.mjs': 'text/javascript; charset=utf-8',
54
+ '.css': 'text/css; charset=utf-8',
55
+ '.json': 'application/json; charset=utf-8',
56
+ '.txt': 'text/plain; charset=utf-8',
57
+ '.svg': 'image/svg+xml',
58
+ '.png': 'image/png',
59
+ '.jpg': 'image/jpeg',
60
+ '.jpeg': 'image/jpeg',
61
+ '.webp': 'image/webp',
62
+ '.avif': 'image/avif',
63
+ '.gif': 'image/gif',
64
+ '.ico': 'image/x-icon',
65
+ '.wasm': 'application/wasm',
66
+ '.woff2': 'font/woff2',
67
+ };
68
+
69
+ /** Options for {@link startDevServer}. */
70
+ export interface DevServerOptions {
71
+ /** Project root; `respond_file` paths resolve against it (and may not escape it). */
72
+ readonly root: string;
73
+ /** Public listening port (the one the browser opens). */
74
+ readonly port: number;
75
+ /** Bind host. Default `127.0.0.1`. */
76
+ readonly host?: string;
77
+ /** Absolute path to the ToilScript server wasm (toilconfig `targets.release.outFile`). */
78
+ readonly wasmFile: string;
79
+ /** The internal Vite dev server to proxy unclaimed traffic to. */
80
+ readonly vite: ViteTarget;
81
+ /** Max request body bytes. Default 8 MB. */
82
+ readonly maxBodyLength?: number;
83
+ }
84
+
85
+ /** A running dev server. */
86
+ export interface RunningDevServer {
87
+ readonly port: number;
88
+ readonly host: string;
89
+ /** Gracefully shuts the front server down (the Vite server is owned by the caller). */
90
+ close(): Promise<void>;
91
+ }
92
+
93
+ /** True for requests that belong to Vite by construction (never offered to the wasm). */
94
+ function isViteInternal(url: string): boolean {
95
+ return VITE_PREFIXES.some((p) => url.startsWith(p));
96
+ }
97
+
98
+ /** Resolves a guest `respond_file` path inside `root`, refusing traversal outside it. */
99
+ function resolveSendfile(root: string, file: string): string | null {
100
+ const resolved = path.resolve(root, file);
101
+ if (resolved !== root && !resolved.startsWith(root + path.sep)) return null;
102
+ if (!fs.existsSync(resolved) || !fs.statSync(resolved).isFile()) return null;
103
+ return resolved;
104
+ }
105
+
106
+ /** Builds the envelope request for one incoming HTTP request. */
107
+ async function toEnvelopeRequest(request: Request): Promise<EnvelopeRequest> {
108
+ const hasBody = request.method !== 'GET' && request.method !== 'HEAD';
109
+ const body = hasBody ? new Uint8Array(await request.buffer()) : new Uint8Array(0);
110
+ return {
111
+ method: request.method,
112
+ // `url` keeps the query string; the guest's RouteContext parses it off the path.
113
+ path: request.url,
114
+ headers: Object.entries(request.headers),
115
+ body,
116
+ };
117
+ }
118
+
119
+ /** Sends a shaped wasm response, mirroring the edge's response defaults. */
120
+ function sendWasmResponse(
121
+ response: Response,
122
+ root: string,
123
+ result: {
124
+ status: number;
125
+ headers: readonly (readonly [string, string])[];
126
+ body: Uint8Array;
127
+ sendfile: string | null;
128
+ },
129
+ ): void {
130
+ response.status(result.status);
131
+ let hasContentType = false;
132
+ for (const [name, value] of result.headers) {
133
+ if (name.toLowerCase() === 'content-type') hasContentType = true;
134
+ response.header(name, value);
135
+ }
136
+ response.header('server', 'toil-dev');
137
+
138
+ if (result.sendfile !== null) {
139
+ const file = resolveSendfile(root, result.sendfile);
140
+ if (file === null) {
141
+ response.status(404).send('not found\n');
142
+ return;
143
+ }
144
+ if (!hasContentType) {
145
+ // The edge defaults file bodies to application/octet-stream; in dev we
146
+ // guess from the extension so a guest-served asset renders in the browser.
147
+ response.header('content-type', MIME[path.extname(file).toLowerCase()] ?? 'application/octet-stream');
148
+ }
149
+ response.sendFile(file);
150
+ return;
151
+ }
152
+
153
+ if (!hasContentType) response.header('content-type', 'text/plain; charset=utf-8');
154
+ response.send(Buffer.from(result.body.buffer, result.body.byteOffset, result.body.length));
155
+ }
156
+
157
+ /**
158
+ * Starts the front server. The caller owns the Vite dev server (start it on a
159
+ * loopback port first) and the toilscript rebuild watcher; this watches only
160
+ * the wasm artifact and hot-swaps the compiled module when it changes.
161
+ */
162
+ export async function startDevServer(options: DevServerOptions): Promise<RunningDevServer> {
163
+ const host = options.host ?? '127.0.0.1';
164
+ const root = path.resolve(options.root);
165
+ const module = new WasmServerModule(options.wasmFile);
166
+
167
+ let warnedMissing = false;
168
+ let loadedOnce = false;
169
+ const refresh = (): void => {
170
+ try {
171
+ if (module.refresh() && loadedOnce) {
172
+ process.stdout.write(pc.green(' ✓ ') + pc.dim('server module reloaded') + '\n');
173
+ }
174
+ loadedOnce ||= module.available;
175
+ } catch (e) {
176
+ process.stdout.write(pc.red(` ✗ server wasm failed to load: ${String(e)}`) + '\n');
177
+ }
178
+ if (!module.available && !warnedMissing) {
179
+ warnedMissing = true;
180
+ process.stdout.write(
181
+ pc.yellow(' ! ') +
182
+ pc.dim(`server wasm not found at ${options.wasmFile}; serving client only`) +
183
+ '\n',
184
+ );
185
+ }
186
+ };
187
+ refresh();
188
+
189
+ const app = new Server({
190
+ max_body_length: options.maxBodyLength ?? DEFAULT_MAX_BODY_LENGTH,
191
+ max_body_buffer: 1024 * 32,
192
+ fast_abort: true,
193
+ });
194
+
195
+ app.set_error_handler((_request: Request, response: Response, error: Error) => {
196
+ if (response.completed) return;
197
+ response.atomic(() => {
198
+ response.status(500).send(`internal error: ${error.message}\n`);
199
+ });
200
+ });
201
+
202
+ wireWebsocketProxy(app, options.vite);
203
+
204
+ app.any('/*', async (request: Request, response: Response) => {
205
+ response.removeHeader('uWebSockets');
206
+
207
+ const dispatchable =
208
+ !isViteInternal(request.url) && METHOD_CODES[request.method] !== undefined;
209
+ if (dispatchable) refresh();
210
+
211
+ if (dispatchable && module.available) {
212
+ const envelopeReq = await toEnvelopeRequest(request);
213
+ try {
214
+ const result = module.dispatch(envelopeReq);
215
+ if (!result.unhandled) {
216
+ sendWasmResponse(response, root, result);
217
+ return;
218
+ }
219
+ } catch (e) {
220
+ // A trap (ToilScript abort, OOB, malformed envelope) is isolated to
221
+ // this request, exactly like the edge poisoning one instance.
222
+ process.stdout.write(
223
+ pc.red(` ✗ ${request.method} ${request.path} server error: ${String(e)}`) + '\n',
224
+ );
225
+ response.status(500).send('internal error\n');
226
+ return;
227
+ }
228
+ }
229
+
230
+ await proxyToVite(request, response, options.vite);
231
+ });
232
+
233
+ await app.listen(options.port, host);
234
+
235
+ return {
236
+ port: options.port,
237
+ host,
238
+ close: async (): Promise<void> => {
239
+ await app.shutdown();
240
+ },
241
+ };
242
+ }