@zuplo/cli 6.73.17 → 6.73.19
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/node_modules/@hono/node-server/README.md +58 -25
- package/node_modules/@hono/node-server/dist/conninfo.cjs +22 -0
- package/node_modules/@hono/node-server/dist/{conninfo.d.ts → conninfo.d.cts} +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.d.mts +4 -3
- package/node_modules/@hono/node-server/dist/conninfo.mjs +19 -16
- package/node_modules/@hono/node-server/dist/constants-BLSFu_RU.mjs +5 -0
- package/node_modules/@hono/node-server/dist/constants-BXAKTxRC.cjs +11 -0
- package/node_modules/@hono/node-server/dist/index.cjs +1173 -0
- package/node_modules/@hono/node-server/dist/index.d.cts +101 -0
- package/node_modules/@hono/node-server/dist/index.d.mts +101 -8
- package/node_modules/@hono/node-server/dist/index.mjs +1143 -637
- package/node_modules/@hono/node-server/dist/serve-static.cjs +151 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.cts +18 -0
- package/node_modules/@hono/node-server/dist/serve-static.d.mts +14 -13
- package/node_modules/@hono/node-server/dist/serve-static.mjs +143 -145
- package/node_modules/@hono/node-server/dist/utils/response.cjs +8 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.cts +4 -0
- package/node_modules/@hono/node-server/dist/utils/response.d.mts +3 -2
- package/node_modules/@hono/node-server/dist/utils/response.mjs +6 -9
- package/node_modules/@hono/node-server/dist/utils/stream.cjs +65 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.cts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.d.mts +6 -0
- package/node_modules/@hono/node-server/dist/utils/stream.mjs +64 -0
- package/node_modules/@hono/node-server/package.json +65 -54
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js +1 -12
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js +17 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js +64 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js +10 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/cjs/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts +7 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js +9 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/client/streamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js +2 -13
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/index.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js +13 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/sseKeepAlive.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts +9 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts +21 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js +239 -41
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/webStandardStreamableHttp.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js +25 -6
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/server/zod-compat.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts +32 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.d.ts.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js +57 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/mediaType.js.map +1 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts +5 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.d.ts.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js +9 -0
- package/node_modules/@modelcontextprotocol/sdk/dist/esm/shared/stdio.js.map +1 -1
- package/node_modules/@modelcontextprotocol/sdk/package.json +4 -3
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js +26 -0
- package/node_modules/@zuplo/otel/out/esm/chunk-JYT2Q52R.js.map +1 -0
- package/node_modules/@zuplo/otel/out/esm/index.js +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-OAVAM6CR.js → chunk-JPPAUB3E.js} +3 -3
- package/node_modules/@zuplo/runtime/out/esm/chunk-JPPAUB3E.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/types/index.d.ts +10 -3
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/express-rate-limit/dist/index.d.cts +10 -12
- package/node_modules/express-rate-limit/dist/index.d.mts +10 -12
- package/node_modules/express-rate-limit/dist/index.d.ts +10 -12
- package/node_modules/express-rate-limit/package.json +5 -5
- package/node_modules/express-rate-limit/readme.md +2 -2
- package/node_modules/ip-address/README.md +102 -100
- package/node_modules/ip-address/dist/common.d.ts +23 -0
- package/node_modules/ip-address/dist/common.js +27 -4
- package/node_modules/ip-address/dist/common.js.map +1 -1
- package/node_modules/ip-address/dist/ipv4.d.ts +7 -0
- package/node_modules/ip-address/dist/ipv4.js +19 -7
- package/node_modules/ip-address/dist/ipv4.js.map +1 -1
- package/node_modules/ip-address/dist/ipv6.d.ts +7 -0
- package/node_modules/ip-address/dist/ipv6.js +38 -25
- package/node_modules/ip-address/dist/ipv6.js.map +1 -1
- package/node_modules/ip-address/dist/v4/constants.js +5 -1
- package/node_modules/ip-address/dist/v4/constants.js.map +1 -1
- package/node_modules/ip-address/package.json +2 -2
- package/package.json +6 -6
- package/node_modules/@hono/node-server/dist/conninfo.js +0 -42
- package/node_modules/@hono/node-server/dist/globals.d.mts +0 -2
- package/node_modules/@hono/node-server/dist/globals.d.ts +0 -2
- package/node_modules/@hono/node-server/dist/globals.js +0 -29
- package/node_modules/@hono/node-server/dist/globals.mjs +0 -5
- package/node_modules/@hono/node-server/dist/index.d.ts +0 -8
- package/node_modules/@hono/node-server/dist/index.js +0 -702
- package/node_modules/@hono/node-server/dist/listener.d.mts +0 -13
- package/node_modules/@hono/node-server/dist/listener.d.ts +0 -13
- package/node_modules/@hono/node-server/dist/listener.js +0 -670
- package/node_modules/@hono/node-server/dist/listener.mjs +0 -635
- package/node_modules/@hono/node-server/dist/request.d.mts +0 -25
- package/node_modules/@hono/node-server/dist/request.d.ts +0 -25
- package/node_modules/@hono/node-server/dist/request.js +0 -238
- package/node_modules/@hono/node-server/dist/request.mjs +0 -206
- package/node_modules/@hono/node-server/dist/response.d.mts +0 -26
- package/node_modules/@hono/node-server/dist/response.d.ts +0 -26
- package/node_modules/@hono/node-server/dist/response.js +0 -112
- package/node_modules/@hono/node-server/dist/response.mjs +0 -85
- package/node_modules/@hono/node-server/dist/serve-static.d.ts +0 -17
- package/node_modules/@hono/node-server/dist/serve-static.js +0 -177
- package/node_modules/@hono/node-server/dist/server.d.mts +0 -10
- package/node_modules/@hono/node-server/dist/server.d.ts +0 -10
- package/node_modules/@hono/node-server/dist/server.js +0 -696
- package/node_modules/@hono/node-server/dist/server.mjs +0 -660
- package/node_modules/@hono/node-server/dist/types.d.mts +0 -44
- package/node_modules/@hono/node-server/dist/types.d.ts +0 -44
- package/node_modules/@hono/node-server/dist/types.js +0 -18
- package/node_modules/@hono/node-server/dist/types.mjs +0 -0
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.mts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response/constants.js +0 -30
- package/node_modules/@hono/node-server/dist/utils/response/constants.mjs +0 -5
- package/node_modules/@hono/node-server/dist/utils/response.d.ts +0 -3
- package/node_modules/@hono/node-server/dist/utils/response.js +0 -37
- package/node_modules/@hono/node-server/dist/utils.d.mts +0 -9
- package/node_modules/@hono/node-server/dist/utils.d.ts +0 -9
- package/node_modules/@hono/node-server/dist/utils.js +0 -99
- package/node_modules/@hono/node-server/dist/utils.mjs +0 -71
- package/node_modules/@hono/node-server/dist/vercel.d.mts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.d.ts +0 -7
- package/node_modules/@hono/node-server/dist/vercel.js +0 -677
- package/node_modules/@hono/node-server/dist/vercel.mjs +0 -640
- package/node_modules/@zuplo/otel/out/esm/chunk-JWNK52ES.js +0 -26
- package/node_modules/@zuplo/otel/out/esm/chunk-JWNK52ES.js.map +0 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-OAVAM6CR.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-OAVAM6CR.js.LEGAL.txt → chunk-JPPAUB3E.js.LEGAL.txt} +0 -0
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Env, Context, MiddlewareHandler } from 'hono';
|
|
2
|
-
|
|
3
|
-
type ServeStaticOptions<E extends Env = Env> = {
|
|
4
|
-
/**
|
|
5
|
-
* Root path, relative to current working directory from which the app was started. Absolute paths are not supported.
|
|
6
|
-
*/
|
|
7
|
-
root?: string;
|
|
8
|
-
path?: string;
|
|
9
|
-
index?: string;
|
|
10
|
-
precompressed?: boolean;
|
|
11
|
-
rewriteRequestPath?: (path: string, c: Context<E>) => string;
|
|
12
|
-
onFound?: (path: string, c: Context<E>) => void | Promise<void>;
|
|
13
|
-
onNotFound?: (path: string, c: Context<E>) => void | Promise<void>;
|
|
14
|
-
};
|
|
15
|
-
declare const serveStatic: <E extends Env = any>(options?: ServeStaticOptions<E>) => MiddlewareHandler<E>;
|
|
16
|
-
|
|
17
|
-
export { type ServeStaticOptions, serveStatic };
|
|
@@ -1,177 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __export = (target, all) => {
|
|
7
|
-
for (var name in all)
|
|
8
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
-
};
|
|
10
|
-
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
-
for (let key of __getOwnPropNames(from))
|
|
13
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
-
}
|
|
16
|
-
return to;
|
|
17
|
-
};
|
|
18
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
|
|
20
|
-
// src/serve-static.ts
|
|
21
|
-
var serve_static_exports = {};
|
|
22
|
-
__export(serve_static_exports, {
|
|
23
|
-
serveStatic: () => serveStatic
|
|
24
|
-
});
|
|
25
|
-
module.exports = __toCommonJS(serve_static_exports);
|
|
26
|
-
var import_mime = require("hono/utils/mime");
|
|
27
|
-
var import_node_fs = require("fs");
|
|
28
|
-
var import_node_path = require("path");
|
|
29
|
-
var import_node_process = require("process");
|
|
30
|
-
var import_node_stream = require("stream");
|
|
31
|
-
var COMPRESSIBLE_CONTENT_TYPE_REGEX = /^\s*(?:text\/[^;\s]+|application\/(?:javascript|json|xml|xml-dtd|ecmascript|dart|postscript|rtf|tar|toml|vnd\.dart|vnd\.ms-fontobject|vnd\.ms-opentype|wasm|x-httpd-php|x-javascript|x-ns-proxy-autoconfig|x-sh|x-tar|x-virtualbox-hdd|x-virtualbox-ova|x-virtualbox-ovf|x-virtualbox-vbox|x-virtualbox-vdi|x-virtualbox-vhd|x-virtualbox-vmdk|x-www-form-urlencoded)|font\/(?:otf|ttf)|image\/(?:bmp|vnd\.adobe\.photoshop|vnd\.microsoft\.icon|vnd\.ms-dds|x-icon|x-ms-bmp)|message\/rfc822|model\/gltf-binary|x-shader\/x-fragment|x-shader\/x-vertex|[^;\s]+?\+(?:json|text|xml|yaml))(?:[;\s]|$)/i;
|
|
32
|
-
var ENCODINGS = {
|
|
33
|
-
br: ".br",
|
|
34
|
-
zstd: ".zst",
|
|
35
|
-
gzip: ".gz"
|
|
36
|
-
};
|
|
37
|
-
var ENCODINGS_ORDERED_KEYS = Object.keys(ENCODINGS);
|
|
38
|
-
var pr54206Applied = () => {
|
|
39
|
-
const [major, minor] = import_node_process.versions.node.split(".").map((component) => parseInt(component));
|
|
40
|
-
return major >= 23 || major === 22 && minor >= 7 || major === 20 && minor >= 18;
|
|
41
|
-
};
|
|
42
|
-
var useReadableToWeb = pr54206Applied();
|
|
43
|
-
var createStreamBody = (stream) => {
|
|
44
|
-
if (useReadableToWeb) {
|
|
45
|
-
return import_node_stream.Readable.toWeb(stream);
|
|
46
|
-
}
|
|
47
|
-
const body = new ReadableStream({
|
|
48
|
-
start(controller) {
|
|
49
|
-
stream.on("data", (chunk) => {
|
|
50
|
-
controller.enqueue(chunk);
|
|
51
|
-
});
|
|
52
|
-
stream.on("error", (err) => {
|
|
53
|
-
controller.error(err);
|
|
54
|
-
});
|
|
55
|
-
stream.on("end", () => {
|
|
56
|
-
controller.close();
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
cancel() {
|
|
60
|
-
stream.destroy();
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
return body;
|
|
64
|
-
};
|
|
65
|
-
var getStats = (path) => {
|
|
66
|
-
let stats;
|
|
67
|
-
try {
|
|
68
|
-
stats = (0, import_node_fs.statSync)(path);
|
|
69
|
-
} catch {
|
|
70
|
-
}
|
|
71
|
-
return stats;
|
|
72
|
-
};
|
|
73
|
-
var tryDecode = (str, decoder) => {
|
|
74
|
-
try {
|
|
75
|
-
return decoder(str);
|
|
76
|
-
} catch {
|
|
77
|
-
return str.replace(/(?:%[0-9A-Fa-f]{2})+/g, (match) => {
|
|
78
|
-
try {
|
|
79
|
-
return decoder(match);
|
|
80
|
-
} catch {
|
|
81
|
-
return match;
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
};
|
|
86
|
-
var tryDecodeURI = (str) => tryDecode(str, decodeURI);
|
|
87
|
-
var serveStatic = (options = { root: "" }) => {
|
|
88
|
-
const root = options.root || "";
|
|
89
|
-
const optionPath = options.path;
|
|
90
|
-
if (root !== "" && !(0, import_node_fs.existsSync)(root)) {
|
|
91
|
-
console.error(`serveStatic: root path '${root}' is not found, are you sure it's correct?`);
|
|
92
|
-
}
|
|
93
|
-
return async (c, next) => {
|
|
94
|
-
if (c.finalized) {
|
|
95
|
-
return next();
|
|
96
|
-
}
|
|
97
|
-
let filename;
|
|
98
|
-
if (optionPath) {
|
|
99
|
-
filename = optionPath;
|
|
100
|
-
} else {
|
|
101
|
-
try {
|
|
102
|
-
filename = tryDecodeURI(c.req.path);
|
|
103
|
-
if (/(?:^|[\/\\])\.{1,2}(?:$|[\/\\])|[\/\\]{2,}|\\/.test(filename)) {
|
|
104
|
-
throw new Error();
|
|
105
|
-
}
|
|
106
|
-
} catch {
|
|
107
|
-
await options.onNotFound?.(c.req.path, c);
|
|
108
|
-
return next();
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
let path = (0, import_node_path.join)(
|
|
112
|
-
root,
|
|
113
|
-
!optionPath && options.rewriteRequestPath ? options.rewriteRequestPath(filename, c) : filename
|
|
114
|
-
);
|
|
115
|
-
let stats = getStats(path);
|
|
116
|
-
if (stats && stats.isDirectory()) {
|
|
117
|
-
const indexFile = options.index ?? "index.html";
|
|
118
|
-
path = (0, import_node_path.join)(path, indexFile);
|
|
119
|
-
stats = getStats(path);
|
|
120
|
-
}
|
|
121
|
-
if (!stats) {
|
|
122
|
-
await options.onNotFound?.(path, c);
|
|
123
|
-
return next();
|
|
124
|
-
}
|
|
125
|
-
const mimeType = (0, import_mime.getMimeType)(path);
|
|
126
|
-
c.header("Content-Type", mimeType || "application/octet-stream");
|
|
127
|
-
if (options.precompressed && (!mimeType || COMPRESSIBLE_CONTENT_TYPE_REGEX.test(mimeType))) {
|
|
128
|
-
const acceptEncodingSet = new Set(
|
|
129
|
-
c.req.header("Accept-Encoding")?.split(",").map((encoding) => encoding.trim())
|
|
130
|
-
);
|
|
131
|
-
for (const encoding of ENCODINGS_ORDERED_KEYS) {
|
|
132
|
-
if (!acceptEncodingSet.has(encoding)) {
|
|
133
|
-
continue;
|
|
134
|
-
}
|
|
135
|
-
const precompressedStats = getStats(path + ENCODINGS[encoding]);
|
|
136
|
-
if (precompressedStats) {
|
|
137
|
-
c.header("Content-Encoding", encoding);
|
|
138
|
-
c.header("Vary", "Accept-Encoding", { append: true });
|
|
139
|
-
stats = precompressedStats;
|
|
140
|
-
path = path + ENCODINGS[encoding];
|
|
141
|
-
break;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
let result;
|
|
146
|
-
const size = stats.size;
|
|
147
|
-
const range = c.req.header("range") || "";
|
|
148
|
-
if (c.req.method == "HEAD" || c.req.method == "OPTIONS") {
|
|
149
|
-
c.header("Content-Length", size.toString());
|
|
150
|
-
c.status(200);
|
|
151
|
-
result = c.body(null);
|
|
152
|
-
} else if (!range) {
|
|
153
|
-
c.header("Content-Length", size.toString());
|
|
154
|
-
result = c.body(createStreamBody((0, import_node_fs.createReadStream)(path)), 200);
|
|
155
|
-
} else {
|
|
156
|
-
c.header("Accept-Ranges", "bytes");
|
|
157
|
-
c.header("Date", stats.birthtime.toUTCString());
|
|
158
|
-
const parts = range.replace(/bytes=/, "").split("-", 2);
|
|
159
|
-
const start = parseInt(parts[0], 10) || 0;
|
|
160
|
-
let end = parseInt(parts[1], 10) || size - 1;
|
|
161
|
-
if (size < end - start + 1) {
|
|
162
|
-
end = size - 1;
|
|
163
|
-
}
|
|
164
|
-
const chunksize = end - start + 1;
|
|
165
|
-
const stream = (0, import_node_fs.createReadStream)(path, { start, end });
|
|
166
|
-
c.header("Content-Length", chunksize.toString());
|
|
167
|
-
c.header("Content-Range", `bytes ${start}-${end}/${stats.size}`);
|
|
168
|
-
result = c.body(createStreamBody(stream), 206);
|
|
169
|
-
}
|
|
170
|
-
await options.onFound?.(path, c);
|
|
171
|
-
return result;
|
|
172
|
-
};
|
|
173
|
-
};
|
|
174
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
175
|
-
0 && (module.exports = {
|
|
176
|
-
serveStatic
|
|
177
|
-
});
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AddressInfo } from 'node:net';
|
|
2
|
-
import { Options, ServerType } from './types.mjs';
|
|
3
|
-
import 'node:http';
|
|
4
|
-
import 'node:http2';
|
|
5
|
-
import 'node:https';
|
|
6
|
-
|
|
7
|
-
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
8
|
-
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
9
|
-
|
|
10
|
-
export { createAdaptorServer, serve };
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { AddressInfo } from 'node:net';
|
|
2
|
-
import { Options, ServerType } from './types.js';
|
|
3
|
-
import 'node:http';
|
|
4
|
-
import 'node:http2';
|
|
5
|
-
import 'node:https';
|
|
6
|
-
|
|
7
|
-
declare const createAdaptorServer: (options: Options) => ServerType;
|
|
8
|
-
declare const serve: (options: Options, listeningListener?: (info: AddressInfo) => void) => ServerType;
|
|
9
|
-
|
|
10
|
-
export { createAdaptorServer, serve };
|