srvx 0.10.1 → 0.11.0
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.
- package/README.md +6 -20
- package/bin/srvx.mjs +5 -3
- package/dist/_chunks/_plugins.mjs +2 -9
- package/dist/_chunks/_url.mjs +33 -25
- package/dist/_chunks/_utils.mjs +14 -73
- package/dist/_chunks/_utils2.mjs +70 -0
- package/dist/_chunks/loader.d.mts +74 -0
- package/dist/_chunks/loader.mjs +108 -0
- package/dist/adapters/aws-lambda.d.mts +19 -0
- package/dist/adapters/aws-lambda.mjs +292 -0
- package/dist/adapters/bun.d.mts +1 -1
- package/dist/adapters/bun.mjs +2 -6
- package/dist/adapters/cloudflare.d.mts +1 -1
- package/dist/adapters/cloudflare.mjs +1 -5
- package/dist/adapters/deno.d.mts +1 -1
- package/dist/adapters/deno.mjs +2 -6
- package/dist/adapters/generic.d.mts +1 -1
- package/dist/adapters/generic.mjs +2 -6
- package/dist/adapters/node.d.mts +1 -1
- package/dist/adapters/node.mjs +164 -84
- package/dist/adapters/service-worker.d.mts +1 -1
- package/dist/adapters/service-worker.mjs +1 -5
- package/dist/cli.d.mts +46 -11
- package/dist/cli.mjs +323 -272
- package/dist/loader.d.mts +2 -0
- package/dist/loader.mjs +2 -0
- package/dist/log.d.mts +1 -1
- package/dist/log.mjs +2 -6
- package/dist/static.d.mts +1 -1
- package/dist/static.mjs +4 -8
- package/dist/tracing.d.mts +1 -2
- package/dist/tracing.mjs +1 -25
- package/dist/types.d.mts +302 -1
- package/package.json +37 -34
- package/dist/_chunks/_color.mjs +0 -18
- package/dist/_chunks/_inherit.mjs +0 -31
- package/dist/_chunks/call.mjs +0 -157
- package/dist/_chunks/call2.mjs +0 -3
- package/dist/_chunks/types.d.mts +0 -283
package/dist/_chunks/call.mjs
DELETED
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
import { t as lazyInherit } from "./_inherit.mjs";
|
|
2
|
-
|
|
3
|
-
//#region src/adapters/_node/response.ts
|
|
4
|
-
/**
|
|
5
|
-
* Fast Response for Node.js runtime
|
|
6
|
-
*
|
|
7
|
-
* It is faster because in most cases it doesn't create a full Response instance.
|
|
8
|
-
*/
|
|
9
|
-
const NodeResponse = /* @__PURE__ */ (() => {
|
|
10
|
-
const NativeResponse = globalThis.Response;
|
|
11
|
-
const STATUS_CODES = globalThis.process?.getBuiltinModule?.("node:http")?.STATUS_CODES || {};
|
|
12
|
-
class NodeResponse$1 {
|
|
13
|
-
#body;
|
|
14
|
-
#init;
|
|
15
|
-
#headers;
|
|
16
|
-
#response;
|
|
17
|
-
constructor(body, init) {
|
|
18
|
-
this.#body = body;
|
|
19
|
-
this.#init = init;
|
|
20
|
-
}
|
|
21
|
-
static [Symbol.hasInstance](val) {
|
|
22
|
-
return val instanceof NativeResponse;
|
|
23
|
-
}
|
|
24
|
-
get status() {
|
|
25
|
-
return this.#response?.status || this.#init?.status || 200;
|
|
26
|
-
}
|
|
27
|
-
get statusText() {
|
|
28
|
-
return this.#response?.statusText || this.#init?.statusText || STATUS_CODES[this.status] || "";
|
|
29
|
-
}
|
|
30
|
-
get headers() {
|
|
31
|
-
if (this.#response) return this.#response.headers;
|
|
32
|
-
if (this.#headers) return this.#headers;
|
|
33
|
-
const initHeaders = this.#init?.headers;
|
|
34
|
-
return this.#headers = initHeaders instanceof Headers ? initHeaders : new Headers(initHeaders);
|
|
35
|
-
}
|
|
36
|
-
get ok() {
|
|
37
|
-
if (this.#response) return this.#response.ok;
|
|
38
|
-
const status = this.status;
|
|
39
|
-
return status >= 200 && status < 300;
|
|
40
|
-
}
|
|
41
|
-
get _response() {
|
|
42
|
-
if (this.#response) return this.#response;
|
|
43
|
-
this.#response = new NativeResponse(this.#body, this.#headers ? {
|
|
44
|
-
...this.#init,
|
|
45
|
-
headers: this.#headers
|
|
46
|
-
} : this.#init);
|
|
47
|
-
this.#init = void 0;
|
|
48
|
-
this.#headers = void 0;
|
|
49
|
-
this.#body = void 0;
|
|
50
|
-
return this.#response;
|
|
51
|
-
}
|
|
52
|
-
_toNodeResponse() {
|
|
53
|
-
const status = this.status;
|
|
54
|
-
const statusText = this.statusText;
|
|
55
|
-
let body;
|
|
56
|
-
let contentType;
|
|
57
|
-
let contentLength;
|
|
58
|
-
if (this.#response) body = this.#response.body;
|
|
59
|
-
else if (this.#body) if (this.#body instanceof ReadableStream) body = this.#body;
|
|
60
|
-
else if (typeof this.#body === "string") {
|
|
61
|
-
body = this.#body;
|
|
62
|
-
contentType = "text/plain; charset=UTF-8";
|
|
63
|
-
contentLength = Buffer.byteLength(this.#body);
|
|
64
|
-
} else if (this.#body instanceof ArrayBuffer) {
|
|
65
|
-
body = Buffer.from(this.#body);
|
|
66
|
-
contentLength = this.#body.byteLength;
|
|
67
|
-
} else if (this.#body instanceof Uint8Array) {
|
|
68
|
-
body = this.#body;
|
|
69
|
-
contentLength = this.#body.byteLength;
|
|
70
|
-
} else if (this.#body instanceof DataView) {
|
|
71
|
-
body = Buffer.from(this.#body.buffer);
|
|
72
|
-
contentLength = this.#body.byteLength;
|
|
73
|
-
} else if (this.#body instanceof Blob) {
|
|
74
|
-
body = this.#body.stream();
|
|
75
|
-
contentType = this.#body.type;
|
|
76
|
-
contentLength = this.#body.size;
|
|
77
|
-
} else if (typeof this.#body.pipe === "function") body = this.#body;
|
|
78
|
-
else body = this._response.body;
|
|
79
|
-
const headers = [];
|
|
80
|
-
const initHeaders = this.#init?.headers;
|
|
81
|
-
const headerEntries = this.#response?.headers || this.#headers || (initHeaders ? Array.isArray(initHeaders) ? initHeaders : initHeaders?.entries ? initHeaders.entries() : Object.entries(initHeaders).map(([k, v]) => [k.toLowerCase(), v]) : void 0);
|
|
82
|
-
let hasContentTypeHeader;
|
|
83
|
-
let hasContentLength;
|
|
84
|
-
if (headerEntries) for (const [key, value] of headerEntries) {
|
|
85
|
-
if (Array.isArray(value)) for (const v of value) headers.push([key, v]);
|
|
86
|
-
else headers.push([key, value]);
|
|
87
|
-
if (key === "content-type") hasContentTypeHeader = true;
|
|
88
|
-
else if (key === "content-length") hasContentLength = true;
|
|
89
|
-
}
|
|
90
|
-
if (contentType && !hasContentTypeHeader) headers.push(["content-type", contentType]);
|
|
91
|
-
if (contentLength && !hasContentLength) headers.push(["content-length", String(contentLength)]);
|
|
92
|
-
this.#init = void 0;
|
|
93
|
-
this.#headers = void 0;
|
|
94
|
-
this.#response = void 0;
|
|
95
|
-
this.#body = void 0;
|
|
96
|
-
return {
|
|
97
|
-
status,
|
|
98
|
-
statusText,
|
|
99
|
-
headers,
|
|
100
|
-
body
|
|
101
|
-
};
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
lazyInherit(NodeResponse$1.prototype, NativeResponse.prototype, "_response");
|
|
105
|
-
Object.setPrototypeOf(NodeResponse$1, NativeResponse);
|
|
106
|
-
Object.setPrototypeOf(NodeResponse$1.prototype, NativeResponse.prototype);
|
|
107
|
-
return NodeResponse$1;
|
|
108
|
-
})();
|
|
109
|
-
|
|
110
|
-
//#endregion
|
|
111
|
-
//#region src/adapters/_node/call.ts
|
|
112
|
-
function callNodeHandler(handler, req) {
|
|
113
|
-
const isMiddleware = handler.length > 2;
|
|
114
|
-
const nodeCtx = req.runtime?.node;
|
|
115
|
-
if (!nodeCtx || !nodeCtx.req || !nodeCtx.res) throw new Error("Node.js runtime context is not available.");
|
|
116
|
-
const { req: nodeReq, res: nodeRes } = nodeCtx;
|
|
117
|
-
let _headers;
|
|
118
|
-
const webRes = new NodeResponse(void 0, {
|
|
119
|
-
get status() {
|
|
120
|
-
return nodeRes.statusCode;
|
|
121
|
-
},
|
|
122
|
-
get statusText() {
|
|
123
|
-
return nodeRes.statusMessage;
|
|
124
|
-
},
|
|
125
|
-
get headers() {
|
|
126
|
-
if (!_headers) {
|
|
127
|
-
const headerEntries = [];
|
|
128
|
-
const rawHeaders = nodeRes.getHeaders();
|
|
129
|
-
for (const [name, value] of Object.entries(rawHeaders)) if (Array.isArray(value)) for (const v of value) headerEntries.push([name, v]);
|
|
130
|
-
else if (value) headerEntries.push([name, String(value)]);
|
|
131
|
-
_headers = new Headers(headerEntries);
|
|
132
|
-
}
|
|
133
|
-
return _headers;
|
|
134
|
-
}
|
|
135
|
-
});
|
|
136
|
-
return new Promise((resolve, reject) => {
|
|
137
|
-
nodeRes.once("close", () => resolve(webRes));
|
|
138
|
-
nodeRes.once("finish", () => resolve(webRes));
|
|
139
|
-
nodeRes.once("error", (error) => reject(error));
|
|
140
|
-
let streamPromise;
|
|
141
|
-
nodeRes.once("pipe", (stream) => {
|
|
142
|
-
streamPromise = new Promise((resolve$1) => {
|
|
143
|
-
stream.once("end", () => resolve$1(webRes));
|
|
144
|
-
stream.once("error", (error) => reject(error));
|
|
145
|
-
});
|
|
146
|
-
});
|
|
147
|
-
try {
|
|
148
|
-
if (isMiddleware) Promise.resolve(handler(nodeReq, nodeRes, (error) => error ? reject(error) : streamPromise || resolve(webRes))).catch((error) => reject(error));
|
|
149
|
-
else Promise.resolve(handler(nodeReq, nodeRes)).then(() => streamPromise || webRes);
|
|
150
|
-
} catch (error) {
|
|
151
|
-
reject(error);
|
|
152
|
-
}
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
//#endregion
|
|
157
|
-
export { NodeResponse as n, callNodeHandler as t };
|
package/dist/_chunks/call2.mjs
DELETED
package/dist/_chunks/types.d.mts
DELETED
|
@@ -1,283 +0,0 @@
|
|
|
1
|
-
import * as NodeHttp from "node:http";
|
|
2
|
-
import * as NodeHttps from "node:https";
|
|
3
|
-
import * as NodeHttp2 from "node:http2";
|
|
4
|
-
import * as cloudflare_workers0 from "cloudflare:workers";
|
|
5
|
-
import * as NodeNet from "node:net";
|
|
6
|
-
import * as Bun from "bun";
|
|
7
|
-
import * as CF from "@cloudflare/workers-types";
|
|
8
|
-
|
|
9
|
-
//#region src/types.d.ts
|
|
10
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
11
|
-
type IsAny<T> = Equal<T, any> extends true ? true : false;
|
|
12
|
-
type Equal<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
13
|
-
/**
|
|
14
|
-
* Faster URL constructor with lazy access to pathname and search params (For Node, Deno, and Bun).
|
|
15
|
-
*/
|
|
16
|
-
declare const FastURL: typeof globalThis.URL;
|
|
17
|
-
/**
|
|
18
|
-
* Faster Response constructor optimized for Node.js (same as Response for other runtimes).
|
|
19
|
-
*/
|
|
20
|
-
declare const FastResponse: typeof globalThis.Response;
|
|
21
|
-
/**
|
|
22
|
-
* Create a new server instance.
|
|
23
|
-
*/
|
|
24
|
-
declare function serve(options: ServerOptions): Server;
|
|
25
|
-
/**
|
|
26
|
-
* Web fetch compatible request handler
|
|
27
|
-
*/
|
|
28
|
-
type ServerHandler = (request: ServerRequest) => MaybePromise<Response>;
|
|
29
|
-
type ServerMiddleware = (request: ServerRequest, next: () => Response | Promise<Response>) => Response | Promise<Response>;
|
|
30
|
-
type ServerPlugin = (server: Server) => void;
|
|
31
|
-
/**
|
|
32
|
-
* Server options
|
|
33
|
-
*/
|
|
34
|
-
interface ServerOptions {
|
|
35
|
-
/**
|
|
36
|
-
* The fetch handler handles incoming requests.
|
|
37
|
-
*/
|
|
38
|
-
fetch: ServerHandler;
|
|
39
|
-
/**
|
|
40
|
-
* Handle lifecycle errors.
|
|
41
|
-
*
|
|
42
|
-
* @note This handler will set built-in Bun and Deno error handler.
|
|
43
|
-
*/
|
|
44
|
-
error?: ErrorHandler;
|
|
45
|
-
/**
|
|
46
|
-
* Server middleware handlers to run before the main fetch handler.
|
|
47
|
-
*/
|
|
48
|
-
middleware?: ServerMiddleware[];
|
|
49
|
-
/**
|
|
50
|
-
* Server plugins.
|
|
51
|
-
*/
|
|
52
|
-
plugins?: ServerPlugin[];
|
|
53
|
-
/**
|
|
54
|
-
* If set to `true`, server will not start listening automatically.
|
|
55
|
-
*/
|
|
56
|
-
manual?: boolean;
|
|
57
|
-
/**
|
|
58
|
-
* The port server should be listening to.
|
|
59
|
-
*
|
|
60
|
-
* Default is read from `PORT` environment variable or will be `3000`.
|
|
61
|
-
*
|
|
62
|
-
* **Tip:** You can set the port to `0` to use a random port.
|
|
63
|
-
*/
|
|
64
|
-
port?: string | number;
|
|
65
|
-
/**
|
|
66
|
-
* The hostname (IP or resolvable host) server listener should bound to.
|
|
67
|
-
*
|
|
68
|
-
* When not provided, server with listen to all network interfaces by default.
|
|
69
|
-
*
|
|
70
|
-
* **Important:** If you are running a server that is not expected to be exposed to the network, use `hostname: "localhost"`.
|
|
71
|
-
*/
|
|
72
|
-
hostname?: string;
|
|
73
|
-
/**
|
|
74
|
-
* Enabling this option allows multiple processes to bind to the same port, which is useful for load balancing.
|
|
75
|
-
*
|
|
76
|
-
* **Note:** Despite Node.js built-in behavior that has `exclusive` flag (opposite of `reusePort`) enabled by default, srvx uses non-exclusive mode for consistency.
|
|
77
|
-
*/
|
|
78
|
-
reusePort?: boolean;
|
|
79
|
-
/**
|
|
80
|
-
* The protocol to use for the server.
|
|
81
|
-
*
|
|
82
|
-
* Possible values are `http` and `https`.
|
|
83
|
-
*
|
|
84
|
-
* If `protocol` is not set, Server will use `http` as the default protocol or `https` if both `tls.cert` and `tls.key` options are provided.
|
|
85
|
-
*/
|
|
86
|
-
protocol?: "http" | "https";
|
|
87
|
-
/**
|
|
88
|
-
* If set to `true`, server will not print the listening address.
|
|
89
|
-
*/
|
|
90
|
-
silent?: boolean;
|
|
91
|
-
/**
|
|
92
|
-
* Graceful shutdown on SIGINT and SIGTERM signals.
|
|
93
|
-
*
|
|
94
|
-
* Supported for Node.js, Deno and Bun runtimes.
|
|
95
|
-
*
|
|
96
|
-
* @default true (disabled in test and ci environments)
|
|
97
|
-
*/
|
|
98
|
-
gracefulShutdown?: boolean | {
|
|
99
|
-
gracefulTimeout?: number;
|
|
100
|
-
forceTimeout?: number;
|
|
101
|
-
};
|
|
102
|
-
/**
|
|
103
|
-
* TLS server options.
|
|
104
|
-
*/
|
|
105
|
-
tls?: {
|
|
106
|
-
/**
|
|
107
|
-
* File path or inlined TLS certificate in PEM format (required).
|
|
108
|
-
*/
|
|
109
|
-
cert?: string;
|
|
110
|
-
/**
|
|
111
|
-
* File path or inlined TLS private key in PEM format (required).
|
|
112
|
-
*/
|
|
113
|
-
key?: string;
|
|
114
|
-
/**
|
|
115
|
-
* Passphrase for the private key (optional).
|
|
116
|
-
*/
|
|
117
|
-
passphrase?: string;
|
|
118
|
-
};
|
|
119
|
-
/**
|
|
120
|
-
* Node.js server options.
|
|
121
|
-
*/
|
|
122
|
-
node?: (NodeHttp.ServerOptions | NodeHttps.ServerOptions | NodeHttp2.ServerOptions) & NodeNet.ListenOptions & {
|
|
123
|
-
http2?: boolean;
|
|
124
|
-
};
|
|
125
|
-
/**
|
|
126
|
-
* Bun server options
|
|
127
|
-
*
|
|
128
|
-
* @docs https://bun.sh/docs/api/http
|
|
129
|
-
*/
|
|
130
|
-
bun?: Omit<Bun.Serve.Options<any>, "fetch">;
|
|
131
|
-
/**
|
|
132
|
-
* Deno server options
|
|
133
|
-
*
|
|
134
|
-
* @docs https://docs.deno.com/api/deno/~/Deno.serve
|
|
135
|
-
*/
|
|
136
|
-
deno?: Deno.ServeOptions;
|
|
137
|
-
/**
|
|
138
|
-
* Service worker options
|
|
139
|
-
*/
|
|
140
|
-
serviceWorker?: {
|
|
141
|
-
/**
|
|
142
|
-
* The path to the service worker file to be registered.
|
|
143
|
-
*/
|
|
144
|
-
url?: string;
|
|
145
|
-
/**
|
|
146
|
-
* The scope of the service worker.
|
|
147
|
-
*
|
|
148
|
-
*/
|
|
149
|
-
scope?: string;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
interface Server<Handler = ServerHandler> {
|
|
153
|
-
/**
|
|
154
|
-
* Current runtime name
|
|
155
|
-
*/
|
|
156
|
-
readonly runtime: "node" | "deno" | "bun" | "cloudflare" | "service-worker" | "generic";
|
|
157
|
-
/**
|
|
158
|
-
* Server options
|
|
159
|
-
*/
|
|
160
|
-
readonly options: ServerOptions & {
|
|
161
|
-
middleware: ServerMiddleware[];
|
|
162
|
-
};
|
|
163
|
-
/**
|
|
164
|
-
* Server URL address.
|
|
165
|
-
*/
|
|
166
|
-
readonly url?: string;
|
|
167
|
-
/**
|
|
168
|
-
* Node.js context.
|
|
169
|
-
*/
|
|
170
|
-
readonly node?: {
|
|
171
|
-
server?: NodeHttp.Server | NodeHttp2.Http2Server;
|
|
172
|
-
handler: (req: NodeServerRequest, res: NodeServerResponse) => void | Promise<void>;
|
|
173
|
-
};
|
|
174
|
-
/**
|
|
175
|
-
* Bun context.
|
|
176
|
-
*/
|
|
177
|
-
readonly bun?: {
|
|
178
|
-
server?: Bun.Server<any>;
|
|
179
|
-
};
|
|
180
|
-
/**
|
|
181
|
-
* Deno context.
|
|
182
|
-
*/
|
|
183
|
-
readonly deno?: {
|
|
184
|
-
server?: Deno.HttpServer;
|
|
185
|
-
};
|
|
186
|
-
/**
|
|
187
|
-
* Server fetch handler
|
|
188
|
-
*/
|
|
189
|
-
readonly fetch: Handler;
|
|
190
|
-
/**
|
|
191
|
-
* Start listening for incoming requests.
|
|
192
|
-
* When `manual` option is enabled, this method needs to be called explicitly to begin accepting connections.
|
|
193
|
-
*/
|
|
194
|
-
serve(): void | Promise<Server<Handler>>;
|
|
195
|
-
/**
|
|
196
|
-
* Returns a promise that resolves when the server is ready.
|
|
197
|
-
*/
|
|
198
|
-
ready(): Promise<Server<Handler>>;
|
|
199
|
-
/**
|
|
200
|
-
* Stop listening to prevent new connections from being accepted.
|
|
201
|
-
*
|
|
202
|
-
* By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
|
|
203
|
-
*
|
|
204
|
-
* @param closeActiveConnections Immediately terminate in-flight requests, websockets, and stop accepting new connections.
|
|
205
|
-
* @default false
|
|
206
|
-
*/
|
|
207
|
-
close(closeActiveConnections?: boolean): Promise<void>;
|
|
208
|
-
}
|
|
209
|
-
interface ServerRuntimeContext {
|
|
210
|
-
name: "node" | "deno" | "bun" | "cloudflare" | (string & {});
|
|
211
|
-
/**
|
|
212
|
-
* Underlying Node.js server request info.
|
|
213
|
-
*/
|
|
214
|
-
node?: {
|
|
215
|
-
req: NodeServerRequest;
|
|
216
|
-
res?: NodeServerResponse;
|
|
217
|
-
};
|
|
218
|
-
/**
|
|
219
|
-
* Underlying Deno server request info.
|
|
220
|
-
*/
|
|
221
|
-
deno?: {
|
|
222
|
-
info: Deno.ServeHandlerInfo<Deno.NetAddr>;
|
|
223
|
-
};
|
|
224
|
-
/**
|
|
225
|
-
* Underlying Bun server request context.
|
|
226
|
-
*/
|
|
227
|
-
bun?: {
|
|
228
|
-
server: Bun.Server<any>;
|
|
229
|
-
};
|
|
230
|
-
/**
|
|
231
|
-
* Underlying Cloudflare request context.
|
|
232
|
-
*/
|
|
233
|
-
cloudflare?: {
|
|
234
|
-
context: CF.ExecutionContext;
|
|
235
|
-
env: IsAny<typeof cloudflare_workers0> extends true ? Record<string, unknown> : typeof cloudflare_workers0.env;
|
|
236
|
-
};
|
|
237
|
-
}
|
|
238
|
-
interface ServerRequestContext {
|
|
239
|
-
[key: string]: unknown;
|
|
240
|
-
}
|
|
241
|
-
interface ServerRequest extends Request {
|
|
242
|
-
/**
|
|
243
|
-
* Access to Node.js native instance of request.
|
|
244
|
-
*
|
|
245
|
-
* See https://srvx.h3.dev/guide/node#noderequest
|
|
246
|
-
*/
|
|
247
|
-
_request?: Request;
|
|
248
|
-
/**
|
|
249
|
-
* Access to the parsed URL
|
|
250
|
-
*/
|
|
251
|
-
_url?: URL;
|
|
252
|
-
/**
|
|
253
|
-
* Runtime specific request context.
|
|
254
|
-
*/
|
|
255
|
-
runtime?: ServerRuntimeContext;
|
|
256
|
-
/**
|
|
257
|
-
* IP address of the client.
|
|
258
|
-
*/
|
|
259
|
-
ip?: string | undefined;
|
|
260
|
-
/**
|
|
261
|
-
* Arbitrary context related to the request.
|
|
262
|
-
*/
|
|
263
|
-
context?: ServerRequestContext;
|
|
264
|
-
/**
|
|
265
|
-
* Tell the runtime about an ongoing operation that shouldn't close until the promise resolves.
|
|
266
|
-
*/
|
|
267
|
-
waitUntil?: (promise: Promise<unknown>) => void | Promise<void>;
|
|
268
|
-
}
|
|
269
|
-
type FetchHandler = (request: Request) => Response | Promise<Response>;
|
|
270
|
-
type ErrorHandler = (error: unknown) => Response | Promise<Response>;
|
|
271
|
-
type BunFetchHandler = (request: Request, server?: Bun.Server<any>) => Response | Promise<Response>;
|
|
272
|
-
type DenoFetchHandler = (request: Request, info?: Deno.ServeHandlerInfo<Deno.NetAddr>) => Response | Promise<Response>;
|
|
273
|
-
type NodeServerRequest = NodeHttp.IncomingMessage | NodeHttp2.Http2ServerRequest;
|
|
274
|
-
type NodeServerResponse = NodeHttp.ServerResponse | NodeHttp2.Http2ServerResponse;
|
|
275
|
-
type NodeHttp1Handler = (req: NodeHttp.IncomingMessage, res: NodeHttp.ServerResponse) => void | Promise<void>;
|
|
276
|
-
type NodeHttp2Handler = (req: NodeHttp2.Http2ServerRequest, res: NodeHttp2.Http2ServerResponse) => void | Promise<void>;
|
|
277
|
-
type NodeHttpHandler = NodeHttp1Handler | NodeHttp2Handler;
|
|
278
|
-
type NodeHTTP1Middleware = (req: NodeHttp.IncomingMessage, res: NodeHttp.ServerResponse, next: (error?: Error) => void) => unknown | Promise<unknown>;
|
|
279
|
-
type NodeHTTP2Middleware = (req: NodeHttp2.Http2ServerRequest, res: NodeHttp2.Http2ServerResponse, next: (error?: Error) => void) => unknown | Promise<unknown>;
|
|
280
|
-
type NodeHTTPMiddleware = NodeHTTP1Middleware | NodeHTTP2Middleware;
|
|
281
|
-
type CloudflareFetchHandler = CF.ExportedHandlerFetchHandler;
|
|
282
|
-
//#endregion
|
|
283
|
-
export { ServerRuntimeContext as C, ServerRequestContext as S, ServerHandler as _, FastResponse as a, ServerPlugin as b, NodeHTTP1Middleware as c, NodeHttp1Handler as d, NodeHttp2Handler as f, Server as g, NodeServerResponse as h, ErrorHandler as i, NodeHTTP2Middleware as l, NodeServerRequest as m, CloudflareFetchHandler as n, FastURL as o, NodeHttpHandler as p, DenoFetchHandler as r, FetchHandler as s, BunFetchHandler as t, NodeHTTPMiddleware as u, ServerMiddleware as v, serve as w, ServerRequest as x, ServerOptions as y };
|