srvx 0.11.8 → 0.11.10
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/_chunks/_plugins.mjs +4 -0
- package/dist/_chunks/_url.mjs +6 -0
- package/dist/_chunks/_utils.mjs +2 -0
- package/dist/_chunks/_utils2.mjs +2 -0
- package/dist/adapters/aws-lambda.mjs +4 -0
- package/dist/adapters/bun.mjs +2 -0
- package/dist/adapters/bunny.mjs +2 -0
- package/dist/adapters/cloudflare.mjs +2 -0
- package/dist/adapters/deno.mjs +2 -0
- package/dist/adapters/generic.mjs +2 -0
- package/dist/adapters/node.mjs +36 -17
- package/dist/adapters/service-worker.mjs +2 -0
- package/dist/cli.mjs +11 -1
- package/dist/loader.mjs +2 -0
- package/dist/log.mjs +2 -0
- package/dist/static.mjs +4 -2
- package/dist/tracing.mjs +2 -0
- package/package.json +17 -17
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as green, i as gray, n as bold, s as red } from "./_utils.mjs";
|
|
2
|
+
//#region src/_middleware.ts
|
|
2
3
|
function wrapFetch(server) {
|
|
3
4
|
const fetchHandler = server.options.fetch;
|
|
4
5
|
const middleware = server.options.middleware || [];
|
|
@@ -8,6 +9,8 @@ function callMiddleware(request, fetchHandler, middleware, index) {
|
|
|
8
9
|
if (index === middleware.length) return fetchHandler(request);
|
|
9
10
|
return middleware[index](request, () => callMiddleware(request, fetchHandler, middleware, index + 1));
|
|
10
11
|
}
|
|
12
|
+
//#endregion
|
|
13
|
+
//#region src/_plugins.ts
|
|
11
14
|
const errorPlugin = (server) => {
|
|
12
15
|
const errorHandler = server.options.error;
|
|
13
16
|
if (!errorHandler) return;
|
|
@@ -53,4 +56,5 @@ const gracefulShutdownPlugin = (server) => {
|
|
|
53
56
|
};
|
|
54
57
|
for (const sig of ["SIGINT", "SIGTERM"]) globalThis.process.on(sig, shutdown);
|
|
55
58
|
};
|
|
59
|
+
//#endregion
|
|
56
60
|
export { gracefulShutdownPlugin as n, wrapFetch as r, errorPlugin as t };
|
package/dist/_chunks/_url.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/_inherit.ts
|
|
1
2
|
function lazyInherit(target, source, sourceKey) {
|
|
2
3
|
for (const key of [...Object.getOwnPropertyNames(source), ...Object.getOwnPropertySymbols(source)]) {
|
|
3
4
|
if (key === "constructor") continue;
|
|
@@ -25,6 +26,9 @@ function lazyInherit(target, source, sourceKey) {
|
|
|
25
26
|
if (modified) Object.defineProperty(target, key, desc);
|
|
26
27
|
}
|
|
27
28
|
}
|
|
29
|
+
//#endregion
|
|
30
|
+
//#region src/_url.ts
|
|
31
|
+
const _needsNormRE = /(?:(?:^|\/)(?:\.|\.\.|%2e|%2e\.|\.%2e|%2e%2e)(?:\/|$))|[\\^\x80-\uffff]/i;
|
|
28
32
|
/**
|
|
29
33
|
* URL wrapper with fast paths to access to the following props:
|
|
30
34
|
*
|
|
@@ -52,6 +56,7 @@ const FastURL = /* @__PURE__ */ (() => {
|
|
|
52
56
|
#pos;
|
|
53
57
|
constructor(url) {
|
|
54
58
|
if (typeof url === "string") this.#href = url;
|
|
59
|
+
else if (_needsNormRE.test(url.pathname)) this.#url = new NativeURL(`${url.protocol || "http:"}//${url.host || "localhost"}${url.pathname}${url.search || ""}`);
|
|
55
60
|
else {
|
|
56
61
|
this.#protocol = url.protocol;
|
|
57
62
|
this.#host = url.host;
|
|
@@ -137,4 +142,5 @@ const FastURL = /* @__PURE__ */ (() => {
|
|
|
137
142
|
Object.setPrototypeOf(FastURL, NativeURL);
|
|
138
143
|
return FastURL;
|
|
139
144
|
})();
|
|
145
|
+
//#endregion
|
|
140
146
|
export { lazyInherit as n, FastURL as t };
|
package/dist/_chunks/_utils.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/cli/_utils.ts
|
|
1
2
|
const noColor = /* @__PURE__ */ (() => {
|
|
2
3
|
const env = globalThis.process?.env ?? {};
|
|
3
4
|
return env.NO_COLOR === "1" || env.TERM === "dumb";
|
|
@@ -12,4 +13,5 @@ const magenta = /* @__PURE__ */ _c(35);
|
|
|
12
13
|
const cyan = /* @__PURE__ */ _c(36);
|
|
13
14
|
const gray = /* @__PURE__ */ _c(90);
|
|
14
15
|
const url = (title, url) => noColor ? `[${title}](${url})` : `\u001B]8;;${url}\u001B\\${title}\u001B]8;;\u001B\\`;
|
|
16
|
+
//#endregion
|
|
15
17
|
export { green as a, url as c, gray as i, yellow as l, bold as n, magenta as o, cyan as r, red as s, blue as t };
|
package/dist/_chunks/_utils2.mjs
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/_utils.ts
|
|
1
2
|
function resolvePortAndHost(opts) {
|
|
2
3
|
const _port = opts.port ?? globalThis.process?.env.PORT ?? 3e3;
|
|
3
4
|
const port = typeof _port === "number" ? _port : Number.parseInt(_port, 10);
|
|
@@ -67,4 +68,5 @@ function createWaitUntil() {
|
|
|
67
68
|
}
|
|
68
69
|
};
|
|
69
70
|
}
|
|
71
|
+
//#endregion
|
|
70
72
|
export { resolveTLSOptions as a, resolvePortAndHost as i, fmtURL as n, printListening as r, createWaitUntil as t };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../_chunks/_utils.mjs";
|
|
2
2
|
import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
3
|
+
//#region src/adapters/_aws/utils.ts
|
|
3
4
|
function awsRequest(event, context) {
|
|
4
5
|
const req = new Request(awsEventURL(event), {
|
|
5
6
|
method: awsEventMethod(event),
|
|
@@ -250,6 +251,8 @@ function createMockContext() {
|
|
|
250
251
|
succeed: () => {}
|
|
251
252
|
};
|
|
252
253
|
}
|
|
254
|
+
//#endregion
|
|
255
|
+
//#region src/adapters/aws-lambda.ts
|
|
253
256
|
function toLambdaHandler(options) {
|
|
254
257
|
const server = new AWSLambdaServer(options);
|
|
255
258
|
return (event, context) => server.fetch(event, context);
|
|
@@ -290,4 +293,5 @@ var AWSLambdaServer = class {
|
|
|
290
293
|
return Promise.resolve();
|
|
291
294
|
}
|
|
292
295
|
};
|
|
296
|
+
//#endregion
|
|
293
297
|
export { handleLambdaEvent, handleLambdaEventWithStream, invokeLambdaHandler, toLambdaHandler };
|
package/dist/adapters/bun.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import "../_chunks/_utils.mjs";
|
|
|
2
2
|
import { t as FastURL } from "../_chunks/_url.mjs";
|
|
3
3
|
import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs";
|
|
4
4
|
import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs";
|
|
5
|
+
//#region src/adapters/bun.ts
|
|
5
6
|
const FastResponse = Response;
|
|
6
7
|
function serve(options) {
|
|
7
8
|
return new BunServer(options);
|
|
@@ -84,4 +85,5 @@ var BunServer = class {
|
|
|
84
85
|
await Promise.all([this.#wait?.wait(), Promise.resolve(this.bun?.server?.stop(closeAll))]);
|
|
85
86
|
}
|
|
86
87
|
};
|
|
88
|
+
//#endregion
|
|
87
89
|
export { FastResponse, FastURL, serve };
|
package/dist/adapters/bunny.mjs
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../_chunks/_utils.mjs";
|
|
2
2
|
import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
3
|
+
//#region src/adapters/bunny.ts
|
|
3
4
|
const FastURL = URL;
|
|
4
5
|
const FastResponse = Response;
|
|
5
6
|
function serve(options) {
|
|
@@ -52,4 +53,5 @@ var BunnyServer = class {
|
|
|
52
53
|
return Promise.resolve();
|
|
53
54
|
}
|
|
54
55
|
};
|
|
56
|
+
//#endregion
|
|
55
57
|
export { FastResponse, FastURL, serve };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../_chunks/_utils.mjs";
|
|
2
2
|
import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
3
|
+
//#region src/adapters/cloudflare.ts
|
|
3
4
|
const FastURL = URL;
|
|
4
5
|
const FastResponse = Response;
|
|
5
6
|
function serve(options) {
|
|
@@ -55,4 +56,5 @@ var CloudflareServer = class {
|
|
|
55
56
|
return Promise.resolve();
|
|
56
57
|
}
|
|
57
58
|
};
|
|
59
|
+
//#endregion
|
|
58
60
|
export { FastResponse, FastURL, serve };
|
package/dist/adapters/deno.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import "../_chunks/_utils.mjs";
|
|
|
2
2
|
import { t as FastURL } from "../_chunks/_url.mjs";
|
|
3
3
|
import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as printListening, t as createWaitUntil } from "../_chunks/_utils2.mjs";
|
|
4
4
|
import { n as gracefulShutdownPlugin, r as wrapFetch } from "../_chunks/_plugins.mjs";
|
|
5
|
+
//#region src/adapters/deno.ts
|
|
5
6
|
const FastResponse = Response;
|
|
6
7
|
function serve(options) {
|
|
7
8
|
return new DenoServer(options);
|
|
@@ -93,4 +94,5 @@ var DenoServer = class {
|
|
|
93
94
|
await Promise.all([this.#wait?.wait(), Promise.resolve(this.deno?.server?.shutdown())]);
|
|
94
95
|
}
|
|
95
96
|
};
|
|
97
|
+
//#endregion
|
|
96
98
|
export { FastResponse, FastURL, serve };
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import "../_chunks/_utils.mjs";
|
|
2
2
|
import { t as createWaitUntil } from "../_chunks/_utils2.mjs";
|
|
3
3
|
import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
4
|
+
//#region src/adapters/generic.ts
|
|
4
5
|
const FastURL = URL;
|
|
5
6
|
const FastResponse = Response;
|
|
6
7
|
function serve(options) {
|
|
@@ -35,4 +36,5 @@ var GenericServer = class {
|
|
|
35
36
|
await this.#wait.wait();
|
|
36
37
|
}
|
|
37
38
|
};
|
|
39
|
+
//#endregion
|
|
38
40
|
export { FastResponse, FastURL, serve };
|
package/dist/adapters/node.mjs
CHANGED
|
@@ -4,8 +4,10 @@ import { a as resolveTLSOptions, i as resolvePortAndHost, n as fmtURL, r as prin
|
|
|
4
4
|
import { n as gracefulShutdownPlugin, r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
5
5
|
import nodeHTTP, { IncomingMessage, ServerResponse } from "node:http";
|
|
6
6
|
import { Duplex, PassThrough, Readable } from "node:stream";
|
|
7
|
+
import { pipeline } from "node:stream/promises";
|
|
7
8
|
import nodeHTTPS from "node:https";
|
|
8
9
|
import nodeHTTP2 from "node:http2";
|
|
10
|
+
//#region src/adapters/_node/send.ts
|
|
9
11
|
async function sendNodeResponse(nodeRes, webRes) {
|
|
10
12
|
if (!webRes) {
|
|
11
13
|
nodeRes.statusCode = 500;
|
|
@@ -16,10 +18,7 @@ async function sendNodeResponse(nodeRes, webRes) {
|
|
|
16
18
|
writeHead(nodeRes, res.status, res.statusText, res.headers);
|
|
17
19
|
if (res.body) {
|
|
18
20
|
if (res.body instanceof ReadableStream) return streamBody(res.body, nodeRes);
|
|
19
|
-
else if (typeof res.body?.pipe === "function")
|
|
20
|
-
res.body.pipe(nodeRes);
|
|
21
|
-
return new Promise((resolve) => nodeRes.on("close", resolve));
|
|
22
|
-
}
|
|
21
|
+
else if (typeof res.body?.pipe === "function") return pipeBody(res.body, nodeRes);
|
|
23
22
|
nodeRes.write(res.body);
|
|
24
23
|
}
|
|
25
24
|
return endNodeResponse(nodeRes);
|
|
@@ -36,6 +35,13 @@ function writeHead(nodeRes, status, statusText, rawHeaders) {
|
|
|
36
35
|
function endNodeResponse(nodeRes) {
|
|
37
36
|
return new Promise((resolve) => nodeRes.end(resolve));
|
|
38
37
|
}
|
|
38
|
+
function pipeBody(stream, nodeRes) {
|
|
39
|
+
if (nodeRes.destroyed) {
|
|
40
|
+
stream.destroy();
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
return pipeline(stream, nodeRes).catch(() => {});
|
|
44
|
+
}
|
|
39
45
|
function streamBody(stream, nodeRes) {
|
|
40
46
|
if (nodeRes.destroyed) {
|
|
41
47
|
stream.cancel();
|
|
@@ -63,6 +69,8 @@ function streamBody(stream, nodeRes) {
|
|
|
63
69
|
nodeRes.off("error", streamCancel);
|
|
64
70
|
});
|
|
65
71
|
}
|
|
72
|
+
//#endregion
|
|
73
|
+
//#region src/adapters/_node/url.ts
|
|
66
74
|
/**
|
|
67
75
|
* Validates an HTTP Host header value (domain, IPv4, or bracketed IPv6) with optional port.
|
|
68
76
|
* Intended for preliminary filtering invalid values like "localhost:3000/foobar?"
|
|
@@ -77,9 +85,8 @@ var NodeRequestURL = class extends FastURL {
|
|
|
77
85
|
const pathname = qIndex === -1 ? path : path?.slice(0, qIndex) || "/";
|
|
78
86
|
const search = qIndex === -1 ? "" : path?.slice(qIndex) || "";
|
|
79
87
|
let host = req.headers.host || req.headers[":authority"];
|
|
80
|
-
if (host)
|
|
81
|
-
|
|
82
|
-
} else if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
|
|
88
|
+
if (host && !HOST_RE.test(host)) host = "_invalid_";
|
|
89
|
+
else if (!host) if (req.socket) host = `${req.socket.localFamily === "IPv6" ? "[" + req.socket.localAddress + "]" : req.socket.localAddress}:${req.socket?.localPort || "80"}`;
|
|
83
90
|
else host = "localhost";
|
|
84
91
|
const protocol = req.socket?.encrypted || req.headers["x-forwarded-proto"] === "https" || req.headers[":scheme"] === "https" ? "https:" : "http:";
|
|
85
92
|
super({
|
|
@@ -99,6 +106,8 @@ var NodeRequestURL = class extends FastURL {
|
|
|
99
106
|
this.#req.url = this._url.pathname + this._url.search;
|
|
100
107
|
}
|
|
101
108
|
};
|
|
109
|
+
//#endregion
|
|
110
|
+
//#region src/adapters/_node/headers.ts
|
|
102
111
|
const NodeRequestHeaders = /* @__PURE__ */ (() => {
|
|
103
112
|
const NativeHeaders = globalThis.Headers;
|
|
104
113
|
class Headers {
|
|
@@ -139,17 +148,8 @@ const NodeRequestHeaders = /* @__PURE__ */ (() => {
|
|
|
139
148
|
const value = this.#req.headers["set-cookie"];
|
|
140
149
|
return Array.isArray(value) ? value : value ? [value] : [];
|
|
141
150
|
}
|
|
142
|
-
*_entries() {
|
|
143
|
-
const rawHeaders = this.#req.rawHeaders;
|
|
144
|
-
const len = rawHeaders.length;
|
|
145
|
-
for (let i = 0; i < len; i += 2) {
|
|
146
|
-
const key = rawHeaders[i];
|
|
147
|
-
if (key.charCodeAt(0) === 58) continue;
|
|
148
|
-
yield [key.toLowerCase(), rawHeaders[i + 1]];
|
|
149
|
-
}
|
|
150
|
-
}
|
|
151
151
|
entries() {
|
|
152
|
-
return this
|
|
152
|
+
return this._headers.entries();
|
|
153
153
|
}
|
|
154
154
|
[Symbol.iterator]() {
|
|
155
155
|
return this.entries();
|
|
@@ -160,6 +160,8 @@ const NodeRequestHeaders = /* @__PURE__ */ (() => {
|
|
|
160
160
|
Object.setPrototypeOf(Headers.prototype, NativeHeaders.prototype);
|
|
161
161
|
return Headers;
|
|
162
162
|
})();
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/adapters/_node/request.ts
|
|
163
165
|
const NodeRequest = /* @__PURE__ */ (() => {
|
|
164
166
|
const NativeRequest = globalThis.Request;
|
|
165
167
|
class Request {
|
|
@@ -299,6 +301,8 @@ function readBody(req) {
|
|
|
299
301
|
req.on("data", onData).once("end", onEnd).once("error", onError);
|
|
300
302
|
});
|
|
301
303
|
}
|
|
304
|
+
//#endregion
|
|
305
|
+
//#region src/adapters/_node/response.ts
|
|
302
306
|
/**
|
|
303
307
|
* Fast Response for Node.js runtime
|
|
304
308
|
*
|
|
@@ -412,6 +416,8 @@ const NodeResponse = /* @__PURE__ */ (() => {
|
|
|
412
416
|
Object.setPrototypeOf(NodeResponse.prototype, NativeResponse.prototype);
|
|
413
417
|
return NodeResponse;
|
|
414
418
|
})();
|
|
419
|
+
//#endregion
|
|
420
|
+
//#region src/adapters/_node/web/socket.ts
|
|
415
421
|
/**
|
|
416
422
|
* Events:
|
|
417
423
|
* - Readable (req from client): readable => data => end (push(null)) => error => close
|
|
@@ -532,6 +538,8 @@ var WebRequestSocket = class extends Duplex {
|
|
|
532
538
|
cb(err ?? void 0);
|
|
533
539
|
}
|
|
534
540
|
};
|
|
541
|
+
//#endregion
|
|
542
|
+
//#region src/adapters/_node/web/incoming.ts
|
|
535
543
|
var WebIncomingMessage = class extends IncomingMessage {
|
|
536
544
|
constructor(req, socket) {
|
|
537
545
|
super(socket);
|
|
@@ -550,6 +558,8 @@ var WebIncomingMessage = class extends IncomingMessage {
|
|
|
550
558
|
});
|
|
551
559
|
}
|
|
552
560
|
};
|
|
561
|
+
//#endregion
|
|
562
|
+
//#region src/adapters/_node/call.ts
|
|
553
563
|
function callNodeHandler(handler, req) {
|
|
554
564
|
const isMiddleware = handler.length > 2;
|
|
555
565
|
const nodeCtx = req.runtime?.node;
|
|
@@ -593,6 +603,8 @@ function callNodeHandler(handler, req) {
|
|
|
593
603
|
}
|
|
594
604
|
});
|
|
595
605
|
}
|
|
606
|
+
//#endregion
|
|
607
|
+
//#region src/adapters/_node/web/response.ts
|
|
596
608
|
var WebServerResponse = class extends ServerResponse {
|
|
597
609
|
#socket;
|
|
598
610
|
constructor(req, socket) {
|
|
@@ -631,6 +643,8 @@ var WebServerResponse = class extends ServerResponse {
|
|
|
631
643
|
});
|
|
632
644
|
}
|
|
633
645
|
};
|
|
646
|
+
//#endregion
|
|
647
|
+
//#region src/adapters/_node/web/fetch.ts
|
|
634
648
|
/**
|
|
635
649
|
* Calls a Node.js HTTP Request handler with a Fetch API Request object and returns a Response object.
|
|
636
650
|
*
|
|
@@ -662,6 +676,8 @@ async function fetchNodeHandler(handler, req) {
|
|
|
662
676
|
});
|
|
663
677
|
}
|
|
664
678
|
}
|
|
679
|
+
//#endregion
|
|
680
|
+
//#region src/adapters/_node/adapter.ts
|
|
665
681
|
/**
|
|
666
682
|
* Converts a Fetch API handler to a Node.js HTTP handler.
|
|
667
683
|
*/
|
|
@@ -697,6 +713,8 @@ function assignFnName(target, source, suffix) {
|
|
|
697
713
|
Object.defineProperty(target, "name", { value: `${source.name}${suffix}` });
|
|
698
714
|
} catch {}
|
|
699
715
|
}
|
|
716
|
+
//#endregion
|
|
717
|
+
//#region src/adapters/node.ts
|
|
700
718
|
function serve(options) {
|
|
701
719
|
return new NodeServer(options);
|
|
702
720
|
}
|
|
@@ -790,4 +808,5 @@ var NodeServer = class {
|
|
|
790
808
|
})]);
|
|
791
809
|
}
|
|
792
810
|
};
|
|
811
|
+
//#endregion
|
|
793
812
|
export { NodeResponse as FastResponse, NodeResponse, FastURL, NodeRequest, fetchNodeHandler, patchGlobalRequest, sendNodeResponse, serve, toFetchHandler, toNodeHandler };
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import "../_chunks/_utils.mjs";
|
|
2
2
|
import { r as wrapFetch, t as errorPlugin } from "../_chunks/_plugins.mjs";
|
|
3
|
+
//#region src/adapters/service-worker.ts
|
|
3
4
|
const FastURL = URL;
|
|
4
5
|
const FastResponse = Response;
|
|
5
6
|
const isBrowserWindow = typeof window !== "undefined" && typeof navigator !== "undefined";
|
|
@@ -74,4 +75,5 @@ var ServiceWorkerServer = class {
|
|
|
74
75
|
} else if (isServiceWorker) await self.registration.unregister();
|
|
75
76
|
}
|
|
76
77
|
};
|
|
78
|
+
//#endregion
|
|
77
79
|
export { FastResponse, FastURL, serve };
|
package/dist/cli.mjs
CHANGED
|
@@ -6,6 +6,7 @@ import { fork } from "node:child_process";
|
|
|
6
6
|
import { createReadStream, existsSync, statSync } from "node:fs";
|
|
7
7
|
import { dirname, relative, resolve } from "node:path";
|
|
8
8
|
import { Readable } from "node:stream";
|
|
9
|
+
//#region src/cli/serve.ts
|
|
9
10
|
const NO_ENTRY_ERROR = "No server entry or public directory found";
|
|
10
11
|
async function cliServe(cliOpts) {
|
|
11
12
|
try {
|
|
@@ -88,6 +89,8 @@ function printInfo(cliOpts, loaded) {
|
|
|
88
89
|
console.log(gray(`${bold(gray("◇"))} Static files: ${staticInfo}`));
|
|
89
90
|
console.log("");
|
|
90
91
|
}
|
|
92
|
+
//#endregion
|
|
93
|
+
//#region src/cli/fetch.ts
|
|
91
94
|
async function cliFetch(cliOpts) {
|
|
92
95
|
const stdin = cliOpts.stdin || process.stdin;
|
|
93
96
|
const stdout = cliOpts.stdout || process.stdout;
|
|
@@ -177,11 +180,15 @@ function getResponseFormat(res) {
|
|
|
177
180
|
encoding: contentType.includes("charset=") ? contentType.split("charset=")[1].split(";")[0].trim() : "utf8"
|
|
178
181
|
};
|
|
179
182
|
}
|
|
183
|
+
//#endregion
|
|
184
|
+
//#region src/cli/_meta.ts
|
|
180
185
|
const srvxMeta = {
|
|
181
186
|
name: "srvx",
|
|
182
|
-
version: "0.11.
|
|
187
|
+
version: "0.11.9",
|
|
183
188
|
description: "Universal Server."
|
|
184
189
|
};
|
|
190
|
+
//#endregion
|
|
191
|
+
//#region src/cli/usage.ts
|
|
185
192
|
function usage(mainOpts) {
|
|
186
193
|
const command = mainOpts.usage?.command || "srvx";
|
|
187
194
|
const name = mainOpts.meta?.name || srvxMeta.name;
|
|
@@ -247,6 +254,8 @@ ${mainOpts.usage?.docs ? `➤ ${url("Documentation", mainOpts.usage.docs)}` : ""
|
|
|
247
254
|
${mainOpts.usage?.issues ? `➤ ${url("Report issues", mainOpts.usage.issues)}` : ""}
|
|
248
255
|
`.trim();
|
|
249
256
|
}
|
|
257
|
+
//#endregion
|
|
258
|
+
//#region src/cli/main.ts
|
|
250
259
|
async function main(mainOpts) {
|
|
251
260
|
const args = process.argv.slice(2);
|
|
252
261
|
const cliOpts = parseArgs$1(args);
|
|
@@ -423,4 +432,5 @@ function runtime() {
|
|
|
423
432
|
else if (process.versions.deno) return `deno ${process.versions.deno}`;
|
|
424
433
|
else return `node ${process.versions.node}`;
|
|
425
434
|
}
|
|
435
|
+
//#endregion
|
|
426
436
|
export { cliFetch, main };
|
package/dist/loader.mjs
CHANGED
|
@@ -3,6 +3,7 @@ import { existsSync } from "node:fs";
|
|
|
3
3
|
import { resolve } from "node:path";
|
|
4
4
|
import * as nodeHTTP$1 from "node:http";
|
|
5
5
|
import { EventEmitter } from "node:events";
|
|
6
|
+
//#region src/loader.ts
|
|
6
7
|
const defaultExts = [
|
|
7
8
|
".mjs",
|
|
8
9
|
".js",
|
|
@@ -135,4 +136,5 @@ var StubNodeServer = class extends EventEmitter {
|
|
|
135
136
|
return this;
|
|
136
137
|
}
|
|
137
138
|
};
|
|
139
|
+
//#endregion
|
|
138
140
|
export { defaultEntries, defaultExts, loadServerEntry };
|
package/dist/log.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { a as green, i as gray, l as yellow, n as bold, s as red, t as blue } from "./_chunks/_utils.mjs";
|
|
2
|
+
//#region src/log.ts
|
|
2
3
|
const statusColors = {
|
|
3
4
|
1: blue,
|
|
4
5
|
2: green,
|
|
@@ -14,4 +15,5 @@ const log = (_options = {}) => {
|
|
|
14
15
|
return res;
|
|
15
16
|
};
|
|
16
17
|
};
|
|
18
|
+
//#endregion
|
|
17
19
|
export { log };
|
package/dist/static.mjs
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
import { t as FastURL } from "./_chunks/_url.mjs";
|
|
2
2
|
import { createReadStream } from "node:fs";
|
|
3
|
-
import { extname, join, resolve } from "node:path";
|
|
3
|
+
import { extname, join, resolve, sep } from "node:path";
|
|
4
4
|
import { readFile, stat } from "node:fs/promises";
|
|
5
5
|
import { FastResponse } from "srvx";
|
|
6
6
|
import { createBrotliCompress, createGzip } from "node:zlib";
|
|
7
|
+
//#region src/static.ts
|
|
7
8
|
const COMMON_MIME_TYPES = {
|
|
8
9
|
".html": "text/html",
|
|
9
10
|
".htm": "text/html",
|
|
@@ -28,7 +29,7 @@ const COMMON_MIME_TYPES = {
|
|
|
28
29
|
".pdf": "application/pdf"
|
|
29
30
|
};
|
|
30
31
|
const serveStatic = (options) => {
|
|
31
|
-
const dir = resolve(options.dir) +
|
|
32
|
+
const dir = resolve(options.dir) + sep;
|
|
32
33
|
const methods = new Set((options.methods || ["GET", "HEAD"]).map((m) => m.toUpperCase()));
|
|
33
34
|
return async (req, next) => {
|
|
34
35
|
if (!methods.has(req.method)) return next();
|
|
@@ -71,4 +72,5 @@ const serveStatic = (options) => {
|
|
|
71
72
|
return next();
|
|
72
73
|
};
|
|
73
74
|
};
|
|
75
|
+
//#endregion
|
|
74
76
|
export { serveStatic };
|
package/dist/tracing.mjs
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "srvx",
|
|
3
|
-
"version": "0.11.
|
|
3
|
+
"version": "0.11.10",
|
|
4
4
|
"description": "Universal Server.",
|
|
5
5
|
"homepage": "https://srvx.h3.dev",
|
|
6
6
|
"license": "MIT",
|
|
@@ -59,38 +59,38 @@
|
|
|
59
59
|
"vitest": "vitest"
|
|
60
60
|
},
|
|
61
61
|
"devDependencies": {
|
|
62
|
-
"@cloudflare/workers-types": "^4.
|
|
63
|
-
"@hono/node-server": "^1.19.
|
|
62
|
+
"@cloudflare/workers-types": "^4.20260313.1",
|
|
63
|
+
"@hono/node-server": "^1.19.11",
|
|
64
64
|
"@mitata/counters": "^0.0.8",
|
|
65
65
|
"@mjackson/node-fetch-server": "^0.7.0",
|
|
66
|
-
"@types/aws-lambda": "^8.10.
|
|
67
|
-
"@types/bun": "^1.3.
|
|
66
|
+
"@types/aws-lambda": "^8.10.161",
|
|
67
|
+
"@types/bun": "^1.3.10",
|
|
68
68
|
"@types/deno": "^2.5.0",
|
|
69
69
|
"@types/express": "^5.0.6",
|
|
70
|
-
"@types/node": "^25.
|
|
70
|
+
"@types/node": "^25.5.0",
|
|
71
71
|
"@types/node-forge": "^1.3.14",
|
|
72
|
-
"@types/serviceworker": "^0.0.
|
|
73
|
-
"@typescript/native-preview": "^7.0.0-dev.
|
|
74
|
-
"@vitest/coverage-v8": "^4.0
|
|
72
|
+
"@types/serviceworker": "^0.0.193",
|
|
73
|
+
"@typescript/native-preview": "^7.0.0-dev.20260315.1",
|
|
74
|
+
"@vitest/coverage-v8": "^4.1.0",
|
|
75
75
|
"@whatwg-node/server": "^0.10.18",
|
|
76
76
|
"automd": "^0.4.3",
|
|
77
77
|
"changelogen": "^0.6.2",
|
|
78
78
|
"eslint-config-unjs": "^0.6.2",
|
|
79
79
|
"execa": "^9.6.1",
|
|
80
80
|
"express": "^5.2.1",
|
|
81
|
-
"fastify": "^5.
|
|
81
|
+
"fastify": "^5.8.2",
|
|
82
82
|
"get-port-please": "^3.2.0",
|
|
83
83
|
"mdbox": "^0.1.1",
|
|
84
84
|
"mitata": "^1.0.34",
|
|
85
85
|
"node-forge": "^1.3.3",
|
|
86
|
-
"obuild": "^0.4.
|
|
87
|
-
"oxfmt": "^0.
|
|
88
|
-
"oxlint": "^1.
|
|
89
|
-
"srvx-release": "npm:srvx@^0.11.
|
|
86
|
+
"obuild": "^0.4.32",
|
|
87
|
+
"oxfmt": "^0.40.0",
|
|
88
|
+
"oxlint": "^1.55.0",
|
|
89
|
+
"srvx-release": "npm:srvx@^0.11.9",
|
|
90
90
|
"tslib": "^2.8.1",
|
|
91
91
|
"typescript": "^5.9.3",
|
|
92
|
-
"undici": "^7.
|
|
93
|
-
"vitest": "^4.0
|
|
92
|
+
"undici": "^7.24.3",
|
|
93
|
+
"vitest": "^4.1.0"
|
|
94
94
|
},
|
|
95
95
|
"resolutions": {
|
|
96
96
|
"srvx": "link:."
|
|
@@ -98,5 +98,5 @@
|
|
|
98
98
|
"engines": {
|
|
99
99
|
"node": ">=20.16.0"
|
|
100
100
|
},
|
|
101
|
-
"packageManager": "pnpm@10.
|
|
101
|
+
"packageManager": "pnpm@10.32.1"
|
|
102
102
|
}
|