srvx 0.7.0 → 0.7.1
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/dist/bun.d.mts +2 -2
- package/dist/bun.mjs +2 -2
- package/dist/{_url.d.mts → chunks/_url-BwTFuoNW.d.mts} +1 -1
- package/dist/{_url.mjs → chunks/_url-CirWh9Lc.mjs} +1 -1
- package/dist/chunks/types-egi3HKdd.d.mts +237 -0
- package/dist/cloudflare.d.mts +1 -1
- package/dist/cloudflare.mjs +2 -2
- package/dist/deno.d.mts +2 -2
- package/dist/deno.mjs +2 -2
- package/dist/generic.d.mts +1 -1
- package/dist/generic.mjs +2 -2
- package/dist/node.d.mts +2 -2
- package/dist/node.mjs +3 -3
- package/dist/service-worker.d.mts +1 -1
- package/dist/service-worker.mjs +2 -2
- package/dist/types.d.mts +2 -228
- package/package.json +2 -2
- /package/dist/{_middleware.mjs → chunks/_middleware-DSFIayTI.mjs} +0 -0
- /package/dist/{_plugins.mjs → chunks/_plugins-BTotWVHV.mjs} +0 -0
package/dist/bun.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { BunFetchHandler, Server, ServerOptions } from "./types.mjs";
|
|
2
|
-
import { FastURL$
|
|
1
|
+
import { BunFetchHandler, Server, ServerOptions } from "./chunks/types-egi3HKdd.mjs";
|
|
2
|
+
import { FastURL$2 as FastURL } from "./chunks/_url-BwTFuoNW.mjs";
|
|
3
3
|
import * as bun from "bun";
|
|
4
4
|
|
|
5
5
|
//#region src/adapters/bun.d.ts
|
package/dist/bun.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./_url.mjs";
|
|
2
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
1
|
+
import { FastURL$1 as FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./chunks/_url-CirWh9Lc.mjs";
|
|
2
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/bun.ts
|
|
5
5
|
const FastResponse = Response;
|
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
import * as NodeHttp$1 from "node:http";
|
|
2
|
+
import * as NodeHttps from "node:https";
|
|
3
|
+
import * as NodeHttp2 from "node:http2";
|
|
4
|
+
import * as NodeNet from "node:net";
|
|
5
|
+
import * as Bun from "bun";
|
|
6
|
+
import * as CF from "@cloudflare/workers-types";
|
|
7
|
+
|
|
8
|
+
//#region src/types.d.ts
|
|
9
|
+
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
+
/**
|
|
11
|
+
* Faster URL constructor with lazy access to pathname and search params (For Node, Deno, and Bun).
|
|
12
|
+
*/
|
|
13
|
+
declare const FastURL: typeof globalThis.URL;
|
|
14
|
+
/**
|
|
15
|
+
* Faster Response constructor optimized for Node.js (same as Response for other runtimes).
|
|
16
|
+
*/
|
|
17
|
+
declare const FastResponse: typeof globalThis.Response;
|
|
18
|
+
/**
|
|
19
|
+
* Create a new server instance.
|
|
20
|
+
*/
|
|
21
|
+
declare function serve(options: ServerOptions): Server;
|
|
22
|
+
/**
|
|
23
|
+
* Web fetch compatible request handler
|
|
24
|
+
*/
|
|
25
|
+
type ServerHandler = (request: ServerRequest) => MaybePromise<Response>;
|
|
26
|
+
type ServerMiddleware = (request: ServerRequest, next: () => Response | Promise<Response>) => Response | Promise<Response>;
|
|
27
|
+
type ServerPlugin = (server: Server) => void;
|
|
28
|
+
/**
|
|
29
|
+
* Server options
|
|
30
|
+
*/
|
|
31
|
+
interface ServerOptions {
|
|
32
|
+
/**
|
|
33
|
+
* The fetch handler handles incoming requests.
|
|
34
|
+
*/
|
|
35
|
+
fetch: ServerHandler;
|
|
36
|
+
/**
|
|
37
|
+
* Handle lifecycle errors.
|
|
38
|
+
*
|
|
39
|
+
* @note This handler will set built-in Bun and Deno error handler.
|
|
40
|
+
*/
|
|
41
|
+
error?: ErrorHandler;
|
|
42
|
+
/**
|
|
43
|
+
* Server middleware handlers to run before the main fetch handler.
|
|
44
|
+
*/
|
|
45
|
+
middleware?: ServerMiddleware[];
|
|
46
|
+
/**
|
|
47
|
+
* Server plugins.
|
|
48
|
+
*/
|
|
49
|
+
plugins?: ServerPlugin[];
|
|
50
|
+
/**
|
|
51
|
+
* If set to `true`, server will not start listening automatically.
|
|
52
|
+
*/
|
|
53
|
+
manual?: boolean;
|
|
54
|
+
/**
|
|
55
|
+
* The port server should be listening to.
|
|
56
|
+
*
|
|
57
|
+
* Default is read from `PORT` environment variable or will be `3000`.
|
|
58
|
+
*
|
|
59
|
+
* **Tip:** You can set the port to `0` to use a random port.
|
|
60
|
+
*/
|
|
61
|
+
port?: string | number;
|
|
62
|
+
/**
|
|
63
|
+
* The hostname (IP or resolvable host) server listener should bound to.
|
|
64
|
+
*
|
|
65
|
+
* When not provided, server with listen to all network interfaces by default.
|
|
66
|
+
*
|
|
67
|
+
* **Important:** If you are running a server that is not expected to be exposed to the network, use `hostname: "localhost"`.
|
|
68
|
+
*/
|
|
69
|
+
hostname?: string;
|
|
70
|
+
/**
|
|
71
|
+
* Enabling this option allows multiple processes to bind to the same port, which is useful for load balancing.
|
|
72
|
+
*
|
|
73
|
+
* **Note:** Despite Node.js built-in behavior that has `exclusive` flag (opposite of `reusePort`) enabled by default, srvx uses non-exclusive mode for consistency.
|
|
74
|
+
*/
|
|
75
|
+
reusePort?: boolean;
|
|
76
|
+
/**
|
|
77
|
+
* The protocol to use for the server.
|
|
78
|
+
*
|
|
79
|
+
* Possible values are `http` and `https`.
|
|
80
|
+
*
|
|
81
|
+
* 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.
|
|
82
|
+
*/
|
|
83
|
+
protocol?: "http" | "https";
|
|
84
|
+
/**
|
|
85
|
+
* If set to `true`, server will not print the listening address.
|
|
86
|
+
*/
|
|
87
|
+
silent?: boolean;
|
|
88
|
+
/**
|
|
89
|
+
* TLS server options.
|
|
90
|
+
*/
|
|
91
|
+
tls?: {
|
|
92
|
+
/**
|
|
93
|
+
* File path or inlined TLS certificate in PEM format (required).
|
|
94
|
+
*/
|
|
95
|
+
cert?: string;
|
|
96
|
+
/**
|
|
97
|
+
* File path or inlined TLS private key in PEM format (required).
|
|
98
|
+
*/
|
|
99
|
+
key?: string;
|
|
100
|
+
/**
|
|
101
|
+
* Passphrase for the private key (optional).
|
|
102
|
+
*/
|
|
103
|
+
passphrase?: string;
|
|
104
|
+
};
|
|
105
|
+
/**
|
|
106
|
+
* Node.js server options.
|
|
107
|
+
*/
|
|
108
|
+
node?: (NodeHttp$1.ServerOptions | NodeHttps.ServerOptions | NodeHttp2.ServerOptions) & NodeNet.ListenOptions & {
|
|
109
|
+
http2?: boolean;
|
|
110
|
+
};
|
|
111
|
+
/**
|
|
112
|
+
* Bun server options
|
|
113
|
+
*
|
|
114
|
+
* @docs https://bun.sh/docs/api/http
|
|
115
|
+
*/
|
|
116
|
+
bun?: Omit<Bun.ServeOptions | Bun.TLSServeOptions, "fetch">;
|
|
117
|
+
/**
|
|
118
|
+
* Deno server options
|
|
119
|
+
*
|
|
120
|
+
* @docs https://docs.deno.com/api/deno/~/Deno.serve
|
|
121
|
+
*/
|
|
122
|
+
deno?: Deno.ServeOptions;
|
|
123
|
+
/**
|
|
124
|
+
* Service worker options
|
|
125
|
+
*/
|
|
126
|
+
serviceWorker?: {
|
|
127
|
+
/**
|
|
128
|
+
* The path to the service worker file to be registered.
|
|
129
|
+
*/
|
|
130
|
+
url?: string;
|
|
131
|
+
/**
|
|
132
|
+
* The scope of the service worker.
|
|
133
|
+
*
|
|
134
|
+
*/
|
|
135
|
+
scope?: string;
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
interface Server<Handler = ServerHandler> {
|
|
139
|
+
/**
|
|
140
|
+
* Current runtime name
|
|
141
|
+
*/
|
|
142
|
+
readonly runtime: "node" | "deno" | "bun" | "cloudflare" | "service-worker" | "generic";
|
|
143
|
+
/**
|
|
144
|
+
* Server options
|
|
145
|
+
*/
|
|
146
|
+
readonly options: ServerOptions & {
|
|
147
|
+
middleware: ServerMiddleware[];
|
|
148
|
+
};
|
|
149
|
+
/**
|
|
150
|
+
* Server URL address.
|
|
151
|
+
*/
|
|
152
|
+
readonly url?: string;
|
|
153
|
+
/**
|
|
154
|
+
* Node.js context.
|
|
155
|
+
*/
|
|
156
|
+
readonly node?: {
|
|
157
|
+
server?: NodeHttp$1.Server | NodeHttp2.Http2Server;
|
|
158
|
+
handler: (req: NodeServerRequest, res: NodeServerResponse) => void | Promise<void>;
|
|
159
|
+
};
|
|
160
|
+
/**
|
|
161
|
+
* Bun context.
|
|
162
|
+
*/
|
|
163
|
+
readonly bun?: {
|
|
164
|
+
server?: Bun.Server;
|
|
165
|
+
};
|
|
166
|
+
/**
|
|
167
|
+
* Deno context.
|
|
168
|
+
*/
|
|
169
|
+
readonly deno?: {
|
|
170
|
+
server?: Deno.HttpServer;
|
|
171
|
+
};
|
|
172
|
+
/**
|
|
173
|
+
* Server fetch handler
|
|
174
|
+
*/
|
|
175
|
+
readonly fetch: Handler;
|
|
176
|
+
/**
|
|
177
|
+
* Returns a promise that resolves when the server is ready.
|
|
178
|
+
*/
|
|
179
|
+
ready(): Promise<Server<Handler>>;
|
|
180
|
+
/**
|
|
181
|
+
* Stop listening to prevent new connections from being accepted.
|
|
182
|
+
*
|
|
183
|
+
* By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
|
|
184
|
+
*
|
|
185
|
+
* @param closeActiveConnections Immediately terminate in-flight requests, websockets, and stop accepting new connections.
|
|
186
|
+
* @default false
|
|
187
|
+
*/
|
|
188
|
+
close(closeActiveConnections?: boolean): Promise<void>;
|
|
189
|
+
}
|
|
190
|
+
interface ServerRuntimeContext {
|
|
191
|
+
name: "node" | "deno" | "bun" | "cloudflare" | (string & {});
|
|
192
|
+
/**
|
|
193
|
+
* Underlying Node.js server request info.
|
|
194
|
+
*/
|
|
195
|
+
node?: {
|
|
196
|
+
req: NodeServerRequest;
|
|
197
|
+
res?: NodeServerResponse;
|
|
198
|
+
};
|
|
199
|
+
/**
|
|
200
|
+
* Underlying Deno server request info.
|
|
201
|
+
*/
|
|
202
|
+
deno?: {
|
|
203
|
+
info: Deno.ServeHandlerInfo<Deno.NetAddr>;
|
|
204
|
+
};
|
|
205
|
+
/**
|
|
206
|
+
* Underlying Bun server request context.
|
|
207
|
+
*/
|
|
208
|
+
bun?: {
|
|
209
|
+
server: Bun.Server;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Underlying Cloudflare request context.
|
|
213
|
+
*/
|
|
214
|
+
cloudflare?: {
|
|
215
|
+
env: unknown;
|
|
216
|
+
context: CF.ExecutionContext;
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
interface ServerRequest extends Request {
|
|
220
|
+
/**
|
|
221
|
+
* Runtime specific request context.
|
|
222
|
+
*/
|
|
223
|
+
runtime?: ServerRuntimeContext;
|
|
224
|
+
/**
|
|
225
|
+
* IP address of the client.
|
|
226
|
+
*/
|
|
227
|
+
ip?: string | undefined;
|
|
228
|
+
}
|
|
229
|
+
type FetchHandler = (request: Request) => Response | Promise<Response>;
|
|
230
|
+
type ErrorHandler = (error: unknown) => Response | Promise<Response>;
|
|
231
|
+
type BunFetchHandler = (request: Request, server?: Bun.Server) => Response | Promise<Response>;
|
|
232
|
+
type DenoFetchHandler = (request: Request, info?: Deno.ServeHandlerInfo<Deno.NetAddr>) => Response | Promise<Response>;
|
|
233
|
+
type NodeServerRequest = NodeHttp$1.IncomingMessage | NodeHttp2.Http2ServerRequest;
|
|
234
|
+
type NodeServerResponse = NodeHttp$1.ServerResponse | NodeHttp2.Http2ServerResponse;
|
|
235
|
+
type NodeHttpHandler = (req: NodeServerRequest, res: NodeServerResponse) => void | Promise<void>;
|
|
236
|
+
type CloudflareFetchHandler = CF.ExportedHandlerFetchHandler; //#endregion
|
|
237
|
+
export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve };
|
package/dist/cloudflare.d.mts
CHANGED
package/dist/cloudflare.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
2
|
-
import { errorPlugin } from "./_plugins.mjs";
|
|
1
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
2
|
+
import { errorPlugin } from "./chunks/_plugins-BTotWVHV.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/cloudflare.ts
|
|
5
5
|
const FastURL = URL;
|
package/dist/deno.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { DenoFetchHandler, Server, ServerOptions } from "./types.mjs";
|
|
2
|
-
import { FastURL$
|
|
1
|
+
import { DenoFetchHandler, Server, ServerOptions } from "./chunks/types-egi3HKdd.mjs";
|
|
2
|
+
import { FastURL$2 as FastURL } from "./chunks/_url-BwTFuoNW.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/deno.d.ts
|
|
5
5
|
declare const FastResponse: typeof globalThis.Response;
|
package/dist/deno.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./_url.mjs";
|
|
2
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
1
|
+
import { FastURL$1 as FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./chunks/_url-CirWh9Lc.mjs";
|
|
2
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/deno.ts
|
|
5
5
|
const FastResponse = Response;
|
package/dist/generic.d.mts
CHANGED
package/dist/generic.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
2
|
-
import { errorPlugin } from "./_plugins.mjs";
|
|
1
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
2
|
+
import { errorPlugin } from "./chunks/_plugins-BTotWVHV.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/generic.ts
|
|
5
5
|
const FastURL = URL;
|
package/dist/node.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "./types.mjs";
|
|
2
|
-
import { FastURL$
|
|
1
|
+
import { FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest } from "./chunks/types-egi3HKdd.mjs";
|
|
2
|
+
import { FastURL$2 as FastURL } from "./chunks/_url-BwTFuoNW.mjs";
|
|
3
3
|
import NodeHttp from "node:http";
|
|
4
4
|
import { Readable } from "node:stream";
|
|
5
5
|
|
package/dist/node.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./_url.mjs";
|
|
2
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
3
|
-
import { errorPlugin } from "./_plugins.mjs";
|
|
1
|
+
import { FastURL$1 as FastURL, fmtURL, printListening, resolvePortAndHost, resolveTLSOptions } from "./chunks/_url-CirWh9Lc.mjs";
|
|
2
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
3
|
+
import { errorPlugin } from "./chunks/_plugins-BTotWVHV.mjs";
|
|
4
4
|
import { splitSetCookieString } from "cookie-es";
|
|
5
5
|
|
|
6
6
|
//#region src/adapters/_node/send.ts
|
package/dist/service-worker.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { wrapFetch } from "./_middleware.mjs";
|
|
2
|
-
import { errorPlugin } from "./_plugins.mjs";
|
|
1
|
+
import { wrapFetch } from "./chunks/_middleware-DSFIayTI.mjs";
|
|
2
|
+
import { errorPlugin } from "./chunks/_plugins-BTotWVHV.mjs";
|
|
3
3
|
|
|
4
4
|
//#region src/adapters/service-worker.ts
|
|
5
5
|
const FastURL = URL;
|
package/dist/types.d.mts
CHANGED
|
@@ -1,228 +1,2 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as NodeHttp2 from "node:http2";
|
|
4
|
-
import * as NodeNet from "node:net";
|
|
5
|
-
import * as Bun from "bun";
|
|
6
|
-
import * as CF from "@cloudflare/workers-types";
|
|
7
|
-
|
|
8
|
-
//#region src/types.d.ts
|
|
9
|
-
type MaybePromise<T> = T | Promise<T>;
|
|
10
|
-
/**
|
|
11
|
-
* Faster URL constructor with lazy access to pathname and search params (For Node, Deno, and Bun).
|
|
12
|
-
*/
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* Web fetch compatible request handler
|
|
16
|
-
*/
|
|
17
|
-
type ServerHandler = (request: ServerRequest) => MaybePromise<Response>;
|
|
18
|
-
type ServerMiddleware = (request: ServerRequest, next: () => Response | Promise<Response>) => Response | Promise<Response>;
|
|
19
|
-
type ServerPlugin = (server: Server) => void;
|
|
20
|
-
/**
|
|
21
|
-
* Server options
|
|
22
|
-
*/
|
|
23
|
-
interface ServerOptions {
|
|
24
|
-
/**
|
|
25
|
-
* The fetch handler handles incoming requests.
|
|
26
|
-
*/
|
|
27
|
-
fetch: ServerHandler;
|
|
28
|
-
/**
|
|
29
|
-
* Handle lifecycle errors.
|
|
30
|
-
*
|
|
31
|
-
* @note This handler will set built-in Bun and Deno error handler.
|
|
32
|
-
*/
|
|
33
|
-
error?: ErrorHandler;
|
|
34
|
-
/**
|
|
35
|
-
* Server middleware handlers to run before the main fetch handler.
|
|
36
|
-
*/
|
|
37
|
-
middleware?: ServerMiddleware[];
|
|
38
|
-
/**
|
|
39
|
-
* Server plugins.
|
|
40
|
-
*/
|
|
41
|
-
plugins?: ServerPlugin[];
|
|
42
|
-
/**
|
|
43
|
-
* If set to `true`, server will not start listening automatically.
|
|
44
|
-
*/
|
|
45
|
-
manual?: boolean;
|
|
46
|
-
/**
|
|
47
|
-
* The port server should be listening to.
|
|
48
|
-
*
|
|
49
|
-
* Default is read from `PORT` environment variable or will be `3000`.
|
|
50
|
-
*
|
|
51
|
-
* **Tip:** You can set the port to `0` to use a random port.
|
|
52
|
-
*/
|
|
53
|
-
port?: string | number;
|
|
54
|
-
/**
|
|
55
|
-
* The hostname (IP or resolvable host) server listener should bound to.
|
|
56
|
-
*
|
|
57
|
-
* When not provided, server with listen to all network interfaces by default.
|
|
58
|
-
*
|
|
59
|
-
* **Important:** If you are running a server that is not expected to be exposed to the network, use `hostname: "localhost"`.
|
|
60
|
-
*/
|
|
61
|
-
hostname?: string;
|
|
62
|
-
/**
|
|
63
|
-
* Enabling this option allows multiple processes to bind to the same port, which is useful for load balancing.
|
|
64
|
-
*
|
|
65
|
-
* **Note:** Despite Node.js built-in behavior that has `exclusive` flag (opposite of `reusePort`) enabled by default, srvx uses non-exclusive mode for consistency.
|
|
66
|
-
*/
|
|
67
|
-
reusePort?: boolean;
|
|
68
|
-
/**
|
|
69
|
-
* The protocol to use for the server.
|
|
70
|
-
*
|
|
71
|
-
* Possible values are `http` and `https`.
|
|
72
|
-
*
|
|
73
|
-
* 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.
|
|
74
|
-
*/
|
|
75
|
-
protocol?: "http" | "https";
|
|
76
|
-
/**
|
|
77
|
-
* If set to `true`, server will not print the listening address.
|
|
78
|
-
*/
|
|
79
|
-
silent?: boolean;
|
|
80
|
-
/**
|
|
81
|
-
* TLS server options.
|
|
82
|
-
*/
|
|
83
|
-
tls?: {
|
|
84
|
-
/**
|
|
85
|
-
* File path or inlined TLS certificate in PEM format (required).
|
|
86
|
-
*/
|
|
87
|
-
cert?: string;
|
|
88
|
-
/**
|
|
89
|
-
* File path or inlined TLS private key in PEM format (required).
|
|
90
|
-
*/
|
|
91
|
-
key?: string;
|
|
92
|
-
/**
|
|
93
|
-
* Passphrase for the private key (optional).
|
|
94
|
-
*/
|
|
95
|
-
passphrase?: string;
|
|
96
|
-
};
|
|
97
|
-
/**
|
|
98
|
-
* Node.js server options.
|
|
99
|
-
*/
|
|
100
|
-
node?: (NodeHttp$1.ServerOptions | NodeHttps.ServerOptions | NodeHttp2.ServerOptions) & NodeNet.ListenOptions & {
|
|
101
|
-
http2?: boolean;
|
|
102
|
-
};
|
|
103
|
-
/**
|
|
104
|
-
* Bun server options
|
|
105
|
-
*
|
|
106
|
-
* @docs https://bun.sh/docs/api/http
|
|
107
|
-
*/
|
|
108
|
-
bun?: Omit<Bun.ServeOptions | Bun.TLSServeOptions, "fetch">;
|
|
109
|
-
/**
|
|
110
|
-
* Deno server options
|
|
111
|
-
*
|
|
112
|
-
* @docs https://docs.deno.com/api/deno/~/Deno.serve
|
|
113
|
-
*/
|
|
114
|
-
deno?: Deno.ServeOptions;
|
|
115
|
-
/**
|
|
116
|
-
* Service worker options
|
|
117
|
-
*/
|
|
118
|
-
serviceWorker?: {
|
|
119
|
-
/**
|
|
120
|
-
* The path to the service worker file to be registered.
|
|
121
|
-
*/
|
|
122
|
-
url?: string;
|
|
123
|
-
/**
|
|
124
|
-
* The scope of the service worker.
|
|
125
|
-
*
|
|
126
|
-
*/
|
|
127
|
-
scope?: string;
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
interface Server<Handler = ServerHandler> {
|
|
131
|
-
/**
|
|
132
|
-
* Current runtime name
|
|
133
|
-
*/
|
|
134
|
-
readonly runtime: "node" | "deno" | "bun" | "cloudflare" | "service-worker" | "generic";
|
|
135
|
-
/**
|
|
136
|
-
* Server options
|
|
137
|
-
*/
|
|
138
|
-
readonly options: ServerOptions & {
|
|
139
|
-
middleware: ServerMiddleware[];
|
|
140
|
-
};
|
|
141
|
-
/**
|
|
142
|
-
* Server URL address.
|
|
143
|
-
*/
|
|
144
|
-
readonly url?: string;
|
|
145
|
-
/**
|
|
146
|
-
* Node.js context.
|
|
147
|
-
*/
|
|
148
|
-
readonly node?: {
|
|
149
|
-
server?: NodeHttp$1.Server | NodeHttp2.Http2Server;
|
|
150
|
-
handler: (req: NodeServerRequest, res: NodeServerResponse) => void | Promise<void>;
|
|
151
|
-
};
|
|
152
|
-
/**
|
|
153
|
-
* Bun context.
|
|
154
|
-
*/
|
|
155
|
-
readonly bun?: {
|
|
156
|
-
server?: Bun.Server;
|
|
157
|
-
};
|
|
158
|
-
/**
|
|
159
|
-
* Deno context.
|
|
160
|
-
*/
|
|
161
|
-
readonly deno?: {
|
|
162
|
-
server?: Deno.HttpServer;
|
|
163
|
-
};
|
|
164
|
-
/**
|
|
165
|
-
* Server fetch handler
|
|
166
|
-
*/
|
|
167
|
-
readonly fetch: Handler;
|
|
168
|
-
/**
|
|
169
|
-
* Returns a promise that resolves when the server is ready.
|
|
170
|
-
*/
|
|
171
|
-
ready(): Promise<Server<Handler>>;
|
|
172
|
-
/**
|
|
173
|
-
* Stop listening to prevent new connections from being accepted.
|
|
174
|
-
*
|
|
175
|
-
* By default, it does not cancel in-flight requests or websockets. That means it may take some time before all network activity stops.
|
|
176
|
-
*
|
|
177
|
-
* @param closeActiveConnections Immediately terminate in-flight requests, websockets, and stop accepting new connections.
|
|
178
|
-
* @default false
|
|
179
|
-
*/
|
|
180
|
-
close(closeActiveConnections?: boolean): Promise<void>;
|
|
181
|
-
}
|
|
182
|
-
interface ServerRuntimeContext {
|
|
183
|
-
name: "node" | "deno" | "bun" | "cloudflare" | (string & {});
|
|
184
|
-
/**
|
|
185
|
-
* Underlying Node.js server request info.
|
|
186
|
-
*/
|
|
187
|
-
node?: {
|
|
188
|
-
req: NodeServerRequest;
|
|
189
|
-
res?: NodeServerResponse;
|
|
190
|
-
};
|
|
191
|
-
/**
|
|
192
|
-
* Underlying Deno server request info.
|
|
193
|
-
*/
|
|
194
|
-
deno?: {
|
|
195
|
-
info: Deno.ServeHandlerInfo<Deno.NetAddr>;
|
|
196
|
-
};
|
|
197
|
-
/**
|
|
198
|
-
* Underlying Bun server request context.
|
|
199
|
-
*/
|
|
200
|
-
bun?: {
|
|
201
|
-
server: Bun.Server;
|
|
202
|
-
};
|
|
203
|
-
/**
|
|
204
|
-
* Underlying Cloudflare request context.
|
|
205
|
-
*/
|
|
206
|
-
cloudflare?: {
|
|
207
|
-
env: unknown;
|
|
208
|
-
context: CF.ExecutionContext;
|
|
209
|
-
};
|
|
210
|
-
}
|
|
211
|
-
interface ServerRequest extends Request {
|
|
212
|
-
/**
|
|
213
|
-
* Runtime specific request context.
|
|
214
|
-
*/
|
|
215
|
-
runtime?: ServerRuntimeContext;
|
|
216
|
-
/**
|
|
217
|
-
* IP address of the client.
|
|
218
|
-
*/
|
|
219
|
-
ip?: string | undefined;
|
|
220
|
-
}
|
|
221
|
-
type FetchHandler = (request: Request) => Response | Promise<Response>;
|
|
222
|
-
type ErrorHandler = (error: unknown) => Response | Promise<Response>;
|
|
223
|
-
type BunFetchHandler = (request: Request, server?: Bun.Server) => Response | Promise<Response>;
|
|
224
|
-
type DenoFetchHandler = (request: Request, info?: Deno.ServeHandlerInfo<Deno.NetAddr>) => Response | Promise<Response>;
|
|
225
|
-
type NodeServerRequest = NodeHttp$1.IncomingMessage | NodeHttp2.Http2ServerRequest;
|
|
226
|
-
type NodeServerResponse = NodeHttp$1.ServerResponse | NodeHttp2.Http2ServerResponse;
|
|
227
|
-
type NodeHttpHandler = (req: NodeServerRequest, res: NodeServerResponse) => void | Promise<void>; //#endregion
|
|
228
|
-
export { BunFetchHandler, DenoFetchHandler, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerOptions, ServerRequest };
|
|
1
|
+
import { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve } from "./chunks/types-egi3HKdd.mjs";
|
|
2
|
+
export { BunFetchHandler, CloudflareFetchHandler, DenoFetchHandler, ErrorHandler, FastResponse, FastURL, FetchHandler, NodeHttpHandler, NodeServerRequest, NodeServerResponse, Server, ServerHandler, ServerMiddleware, ServerOptions, ServerPlugin, ServerRequest, ServerRuntimeContext, serve };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.1",
|
|
4
4
|
"description": "Universal Server API based on web platform standards. Works seamlessly with Deno, Bun and Node.js.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"repository": "h3js/srvx",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"get-port-please": "^3.1.2",
|
|
76
76
|
"mitata": "^1.0.34",
|
|
77
77
|
"node-forge": "^1.3.1",
|
|
78
|
-
"obuild": "^0.0.
|
|
78
|
+
"obuild": "^0.0.7",
|
|
79
79
|
"prettier": "^3.5.3",
|
|
80
80
|
"typescript": "^5.8.3",
|
|
81
81
|
"undici": "^7.9.0",
|
|
File without changes
|
|
File without changes
|