sevok 0.0.2
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/LICENSE +21 -0
- package/README.md +342 -0
- package/README.zh-CN.md +342 -0
- package/bin/sevok.mjs +13 -0
- package/dist/_color-B42q-MpL.mjs +34 -0
- package/dist/_node_like-BRaAGeNM.mjs +112 -0
- package/dist/_shared-38k_JIsU.mjs +92 -0
- package/dist/bun.d.mts +31 -0
- package/dist/bun.mjs +58 -0
- package/dist/cli.d.mts +142 -0
- package/dist/cli.mjs +461 -0
- package/dist/core-BGp2ZR_k.d.mts +665 -0
- package/dist/core-CmUugTW7.mjs +732 -0
- package/dist/deno.d.mts +32 -0
- package/dist/deno.mjs +65 -0
- package/dist/index.d.mts +2 -0
- package/dist/index.mjs +2 -0
- package/dist/log.d.mts +27 -0
- package/dist/log.mjs +26 -0
- package/dist/node.d.mts +32 -0
- package/dist/node.mjs +139 -0
- package/dist/static.d.mts +35 -0
- package/dist/static.mjs +100 -0
- package/dist/stream.d.mts +56 -0
- package/dist/stream.mjs +68 -0
- package/package.json +68 -0
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/_color.ts
|
|
2
|
+
const noColor = /* @__PURE__ */ (() => {
|
|
3
|
+
const p = globalThis.process || {};
|
|
4
|
+
const argv = p.argv || [];
|
|
5
|
+
const env = p.env || {};
|
|
6
|
+
return !(!(!!env.NO_COLOR || argv.includes("--no-color")) && (!!env.FORCE_COLOR || argv.includes("--color") || p.platform === "win32" || (p.stdout || {}).isTTY && env.TERM !== "dumb" || !!env.CI));
|
|
7
|
+
})();
|
|
8
|
+
const w = (c, r = 39) => {
|
|
9
|
+
return (t) => noColor ? t : `\u001B[${c}m${t}\u001B[${r}m`;
|
|
10
|
+
};
|
|
11
|
+
const bold = /* @__PURE__ */ w(1, 22);
|
|
12
|
+
const red = /* @__PURE__ */ w(31);
|
|
13
|
+
const green = /* @__PURE__ */ w(32);
|
|
14
|
+
const yellow = /* @__PURE__ */ w(33);
|
|
15
|
+
const blue = /* @__PURE__ */ w(34);
|
|
16
|
+
const magenta = /* @__PURE__ */ w(35);
|
|
17
|
+
const cyan = /* @__PURE__ */ w(36);
|
|
18
|
+
const gray = /* @__PURE__ */ w(90);
|
|
19
|
+
const url = (title, url) => {
|
|
20
|
+
return noColor ? `[${title}](${url})` : `\u001B]8;;${url}\u001B\\${title}\u001B]8;;\u001B\\`;
|
|
21
|
+
};
|
|
22
|
+
var _color_default = {
|
|
23
|
+
bold,
|
|
24
|
+
red,
|
|
25
|
+
green,
|
|
26
|
+
yellow,
|
|
27
|
+
blue,
|
|
28
|
+
magenta,
|
|
29
|
+
cyan,
|
|
30
|
+
gray,
|
|
31
|
+
url
|
|
32
|
+
};
|
|
33
|
+
//#endregion
|
|
34
|
+
export { _color_default as t };
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
import { readFileSync } from "node:fs";
|
|
2
|
+
//#region src/_node_like.ts
|
|
3
|
+
/**
|
|
4
|
+
* Normalize TLS options for runtimes that accept PEM strings.
|
|
5
|
+
*
|
|
6
|
+
* Certificate and key values may be supplied inline or as filesystem paths.
|
|
7
|
+
*/
|
|
8
|
+
function resolveTLSOptions(opts) {
|
|
9
|
+
if (!opts.tls || opts.protocol === "http") return;
|
|
10
|
+
const cert = resolveCertOrKey(opts.tls.cert);
|
|
11
|
+
const key = resolveCertOrKey(opts.tls.key);
|
|
12
|
+
if (!cert && !key) {
|
|
13
|
+
if (opts.protocol === "https") throw new TypeError("TLS `cert` and `key` must be provided for `https` protocol.");
|
|
14
|
+
return;
|
|
15
|
+
}
|
|
16
|
+
if (!cert || !key) throw new TypeError("TLS `cert` and `key` must be provided together.");
|
|
17
|
+
return {
|
|
18
|
+
cert,
|
|
19
|
+
key,
|
|
20
|
+
passphrase: opts.tls.passphrase
|
|
21
|
+
};
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Accept either inline PEM content or a path to a PEM file on disk.
|
|
25
|
+
*/
|
|
26
|
+
function resolveCertOrKey(value) {
|
|
27
|
+
if (!value) return;
|
|
28
|
+
if (typeof value !== "string") throw new TypeError("TLS certificate and key must be strings in PEM format or file paths.");
|
|
29
|
+
if (value.startsWith("-----BEGIN ")) return value;
|
|
30
|
+
return readFileSync(value, "utf8");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Print the listener address unless output is silenced.
|
|
34
|
+
*
|
|
35
|
+
* When the runtime binds to all interfaces, the displayed URL is rewritten to
|
|
36
|
+
* `localhost` so the message remains copy-pastable for local development.
|
|
37
|
+
*/
|
|
38
|
+
function printListening(opts, url) {
|
|
39
|
+
if (!url || (opts.silent ?? globalThis.process?.env?.TEST)) return;
|
|
40
|
+
let additionalInfo = "";
|
|
41
|
+
try {
|
|
42
|
+
const _url = new URL(url);
|
|
43
|
+
if (_url.hostname === "[::]" || _url.hostname === "0.0.0.0") {
|
|
44
|
+
_url.hostname = "localhost";
|
|
45
|
+
url = _url.href;
|
|
46
|
+
additionalInfo = " (all interfaces)";
|
|
47
|
+
}
|
|
48
|
+
} catch {}
|
|
49
|
+
let listeningOn = `➜ Listening on:`;
|
|
50
|
+
if (globalThis.process.stdout?.isTTY) {
|
|
51
|
+
listeningOn = `\u001B[32m${listeningOn}\u001B[0m`;
|
|
52
|
+
url = `\u001B[36m${url}\u001B[0m`;
|
|
53
|
+
additionalInfo = `\u001B[2m${additionalInfo}\u001B[0m`;
|
|
54
|
+
}
|
|
55
|
+
console.log(`${listeningOn} ${url}${additionalInfo}`);
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Runtime helpers shared by Bun and Node-style adapters.
|
|
59
|
+
*/
|
|
60
|
+
const runtimeCapabilities = {
|
|
61
|
+
resolve: resolveNodeLikePath,
|
|
62
|
+
open: openNodeLikePath,
|
|
63
|
+
createGzip: createNodeLikeGzip,
|
|
64
|
+
createBrotliCompress: createNodeLikeBrotliCompress
|
|
65
|
+
};
|
|
66
|
+
/**
|
|
67
|
+
* Resolve a candidate path and reject traversal outside the configured root.
|
|
68
|
+
*/
|
|
69
|
+
async function resolveNodeLikePath(root, ...components) {
|
|
70
|
+
const { resolve, sep } = await import("node:path");
|
|
71
|
+
const resolvedRoot = resolve(root);
|
|
72
|
+
const resolvedPath = resolve(resolvedRoot, ...components);
|
|
73
|
+
return resolvedPath === resolvedRoot || resolvedPath.startsWith(`${resolvedRoot}${sep}`) ? resolvedPath : null;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Open a file lazily and expose it as a Web `ReadableStream`.
|
|
77
|
+
*/
|
|
78
|
+
async function openNodeLikePath(path) {
|
|
79
|
+
const { stat } = await import("node:fs/promises");
|
|
80
|
+
const fileStat = await stat(path).catch(() => null);
|
|
81
|
+
if (!fileStat) return null;
|
|
82
|
+
const { createReadStream } = await import("node:fs");
|
|
83
|
+
const { Readable } = await import("node:stream");
|
|
84
|
+
return {
|
|
85
|
+
isFile: fileStat.isFile(),
|
|
86
|
+
size: fileStat.size,
|
|
87
|
+
stream(start, end) {
|
|
88
|
+
return Readable.toWeb(createReadStream(path, {
|
|
89
|
+
start,
|
|
90
|
+
end: typeof end === "number" ? end - 1 : void 0
|
|
91
|
+
}));
|
|
92
|
+
}
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Adapt Node's gzip transform to the Web Streams API used by this package.
|
|
97
|
+
*/
|
|
98
|
+
async function createNodeLikeGzip() {
|
|
99
|
+
const { createGzip } = await import("node:zlib");
|
|
100
|
+
const { Duplex } = await import("node:stream");
|
|
101
|
+
return Duplex.toWeb(createGzip());
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Adapt Node's Brotli transform to the Web Streams API used by this package.
|
|
105
|
+
*/
|
|
106
|
+
async function createNodeLikeBrotliCompress() {
|
|
107
|
+
const { createBrotliCompress } = await import("node:zlib");
|
|
108
|
+
const { Duplex } = await import("node:stream");
|
|
109
|
+
return Duplex.toWeb(createBrotliCompress());
|
|
110
|
+
}
|
|
111
|
+
//#endregion
|
|
112
|
+
export { resolveTLSOptions as n, runtimeCapabilities as r, printListening as t };
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
//#region src/_shared.ts
|
|
2
|
+
/**
|
|
3
|
+
* Normalize a pathname to a leading-slash, no-trailing-slash form.
|
|
4
|
+
*/
|
|
5
|
+
function normalizePathname(pathname) {
|
|
6
|
+
if (pathname.length === 0 || pathname === "/") return "/";
|
|
7
|
+
let normalized = pathname.startsWith("/") ? pathname : `/${pathname}`;
|
|
8
|
+
normalized = normalized.replace(/\/+/g, "/");
|
|
9
|
+
if (normalized.length > 1 && normalized.endsWith("/")) normalized = normalized.slice(0, -1);
|
|
10
|
+
return normalized;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Split a normalized pathname into path segments.
|
|
14
|
+
*/
|
|
15
|
+
function splitPathname(pathname) {
|
|
16
|
+
const normalized = normalizePathname(pathname);
|
|
17
|
+
return normalized === "/" ? [] : normalized.slice(1).split("/");
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* Escape a string for safe inclusion in a regular expression.
|
|
21
|
+
*/
|
|
22
|
+
function escapeRegExp(value) {
|
|
23
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Compile a route pathname into a matching regular expression.
|
|
27
|
+
*/
|
|
28
|
+
function compilePath(path) {
|
|
29
|
+
const segments = splitPathname(path);
|
|
30
|
+
if (segments.length === 0) return /^\/$/;
|
|
31
|
+
const source = segments.map((segment) => {
|
|
32
|
+
if (segment === "*") return "(?:/.*)?";
|
|
33
|
+
if (segment.startsWith(":")) return "/([^/]+)";
|
|
34
|
+
return `/${escapeRegExp(segment)}`;
|
|
35
|
+
}).join("");
|
|
36
|
+
return new RegExp(`^${source}$`);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Extract route parameter names from a path pattern.
|
|
40
|
+
*/
|
|
41
|
+
function extractKeys(path) {
|
|
42
|
+
return splitPathname(path).filter((segment) => segment.startsWith(":")).map((segment) => segment.slice(1));
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Collapse dynamic route segments into a canonical conflict-detection pattern.
|
|
46
|
+
*/
|
|
47
|
+
function canonicalizePath(path) {
|
|
48
|
+
const segments = splitPathname(path).map((segment) => {
|
|
49
|
+
if (segment === "*") return "*";
|
|
50
|
+
if (segment.startsWith(":")) return ":";
|
|
51
|
+
return segment;
|
|
52
|
+
});
|
|
53
|
+
return segments.length === 0 ? "/" : `/${segments.join("/")}`;
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Extract named params from a regular-expression route match.
|
|
57
|
+
*/
|
|
58
|
+
function extractParams(keys, match) {
|
|
59
|
+
const params = {};
|
|
60
|
+
for (const [index, key] of keys.entries()) {
|
|
61
|
+
const value = match[index + 1];
|
|
62
|
+
if (value != null) params[key] = decodeURIComponent(value);
|
|
63
|
+
}
|
|
64
|
+
return params;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Resolve the effective listening port and hostname from explicit options or
|
|
68
|
+
* the conventional `PORT` and `HOST` environment variables.
|
|
69
|
+
*/
|
|
70
|
+
function resolvePortAndHost(opts) {
|
|
71
|
+
const _port = opts.port ?? globalThis.process?.env.PORT ?? 3e3;
|
|
72
|
+
const port = typeof _port === "number" ? _port : Number.parseInt(_port, 10);
|
|
73
|
+
if (port < 0 || port > 65535) throw new RangeError(`Port must be between 0 and 65535 (got "${port}").`);
|
|
74
|
+
return {
|
|
75
|
+
port,
|
|
76
|
+
hostname: opts.hostname ?? globalThis.process?.env.HOST
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Format a listener address as a fetch-compatible origin.
|
|
81
|
+
*
|
|
82
|
+
* Returns `undefined` when either host or port is missing, which keeps callers
|
|
83
|
+
* from printing misleading partial URLs before the runtime has finished
|
|
84
|
+
* listening.
|
|
85
|
+
*/
|
|
86
|
+
function fmtURL(host, port, secure) {
|
|
87
|
+
if (!host || !port) return;
|
|
88
|
+
if (host.includes(":")) host = `[${host}]`;
|
|
89
|
+
return `http${secure ? "s" : ""}://${host}:${port}/`;
|
|
90
|
+
}
|
|
91
|
+
//#endregion
|
|
92
|
+
export { fmtURL as a, extractParams as i, compilePath as n, normalizePathname as o, extractKeys as r, resolvePortAndHost as s, canonicalizePath as t };
|
package/dist/bun.d.mts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { d as RuntimeAdapter, f as RuntimeCapabilities, p as Server } from "./core-BGp2ZR_k.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/bun.d.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runtime adapter that backs `Server` with `Bun.serve()`.
|
|
6
|
+
*/
|
|
7
|
+
declare class BunRuntimeAdapter implements RuntimeAdapter {
|
|
8
|
+
#private;
|
|
9
|
+
readonly graceful = true;
|
|
10
|
+
get capabilities(): RuntimeCapabilities;
|
|
11
|
+
/**
|
|
12
|
+
* Merge generic server options with Bun-specific listener options.
|
|
13
|
+
*/
|
|
14
|
+
setup(server: Server): void;
|
|
15
|
+
/**
|
|
16
|
+
* Start Bun's native server once and reuse the same instance for later calls.
|
|
17
|
+
*/
|
|
18
|
+
serve(server: Server): Promise<{
|
|
19
|
+
url: string | undefined;
|
|
20
|
+
}>;
|
|
21
|
+
/**
|
|
22
|
+
* Expose Bun's resolved listener URL.
|
|
23
|
+
*/
|
|
24
|
+
get url(): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Stop the active Bun server and clear the cached instance.
|
|
27
|
+
*/
|
|
28
|
+
close(closeActiveConnections?: boolean): Promise<void>;
|
|
29
|
+
}
|
|
30
|
+
//#endregion
|
|
31
|
+
export { BunRuntimeAdapter };
|
package/dist/bun.mjs
ADDED
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { n as resolveTLSOptions, r as runtimeCapabilities, t as printListening } from "./_node_like-BRaAGeNM.mjs";
|
|
2
|
+
import { s as resolvePortAndHost } from "./_shared-38k_JIsU.mjs";
|
|
3
|
+
//#region src/bun.ts
|
|
4
|
+
/**
|
|
5
|
+
* Runtime adapter that backs `Server` with `Bun.serve()`.
|
|
6
|
+
*/
|
|
7
|
+
var BunRuntimeAdapter = class {
|
|
8
|
+
#server;
|
|
9
|
+
#serveOptions;
|
|
10
|
+
graceful = true;
|
|
11
|
+
get capabilities() {
|
|
12
|
+
return runtimeCapabilities;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Merge generic server options with Bun-specific listener options.
|
|
16
|
+
*/
|
|
17
|
+
setup(server) {
|
|
18
|
+
const { options } = server;
|
|
19
|
+
const { hostname, port } = resolvePortAndHost(options);
|
|
20
|
+
const tls = resolveTLSOptions(options);
|
|
21
|
+
this.#serveOptions = {
|
|
22
|
+
hostname,
|
|
23
|
+
port,
|
|
24
|
+
reusePort: options.reusePort,
|
|
25
|
+
error: options.error,
|
|
26
|
+
...options.bun,
|
|
27
|
+
fetch: (request) => server.fetch(request),
|
|
28
|
+
tls: {
|
|
29
|
+
...tls,
|
|
30
|
+
...options.bun?.tls
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Start Bun's native server once and reuse the same instance for later calls.
|
|
36
|
+
*/
|
|
37
|
+
serve(server) {
|
|
38
|
+
if (!this.#server) this.#server = Bun.serve(this.#serveOptions);
|
|
39
|
+
printListening(server.options, this.url);
|
|
40
|
+
return Promise.resolve({ url: this.url });
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Expose Bun's resolved listener URL.
|
|
44
|
+
*/
|
|
45
|
+
get url() {
|
|
46
|
+
return this.#server?.url.href;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Stop the active Bun server and clear the cached instance.
|
|
50
|
+
*/
|
|
51
|
+
async close(closeActiveConnections = false) {
|
|
52
|
+
return Promise.resolve(this.#server?.stop(closeActiveConnections)).then(() => {
|
|
53
|
+
this.#server = void 0;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
//#endregion
|
|
58
|
+
export { BunRuntimeAdapter };
|
package/dist/cli.d.mts
ADDED
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { d as RuntimeAdapter, v as ServerHandler } from "./core-BGp2ZR_k.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/cli.d.ts
|
|
4
|
+
declare const defaultExts: string[];
|
|
5
|
+
declare const defaultEntries: string[];
|
|
6
|
+
/**
|
|
7
|
+
* Result of loading a server entry module.
|
|
8
|
+
*/
|
|
9
|
+
type LoadedServerEntry = {
|
|
10
|
+
/**
|
|
11
|
+
* The web fetch handler extracted from the loaded module.
|
|
12
|
+
*
|
|
13
|
+
* This is resolved by `loadServerEntry()` from:
|
|
14
|
+
* - `module.fetch`
|
|
15
|
+
* - `module.default.fetch`
|
|
16
|
+
* - or a default-exported function with fewer than two parameters
|
|
17
|
+
*/
|
|
18
|
+
fetch?: ServerHandler;
|
|
19
|
+
/**
|
|
20
|
+
* The normalized loaded module.
|
|
21
|
+
*
|
|
22
|
+
* In practice this is usually the user entry object shape after
|
|
23
|
+
* `loadServerEntry()` unwraps a plain object default export.
|
|
24
|
+
*
|
|
25
|
+
* This follows the `UserServerEntry` structure for value access,
|
|
26
|
+
* though typed as `any` for flexibility.
|
|
27
|
+
*/
|
|
28
|
+
module?: any;
|
|
29
|
+
/**
|
|
30
|
+
* The resolved `file://` URL of the loaded entry module.
|
|
31
|
+
*/
|
|
32
|
+
url?: string;
|
|
33
|
+
/**
|
|
34
|
+
* Whether the specified entry file was not found.
|
|
35
|
+
*
|
|
36
|
+
* When `true`, no valid entry point could be located.
|
|
37
|
+
*/
|
|
38
|
+
notFound?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Runtime adapter selected for the current process.
|
|
41
|
+
*
|
|
42
|
+
* This value is resolved by `loadServerAdapter()` based on the active runtime
|
|
43
|
+
* (Bun, Deno, or Node.js) together with any runtime-specific options exposed
|
|
44
|
+
* from the user entry module.
|
|
45
|
+
*/
|
|
46
|
+
adapter: RuntimeAdapter;
|
|
47
|
+
};
|
|
48
|
+
/**
|
|
49
|
+
* Options for loading a server entry module.
|
|
50
|
+
*/
|
|
51
|
+
type LoadOptions = {
|
|
52
|
+
/**
|
|
53
|
+
* Path or URL to the server entry file.
|
|
54
|
+
*
|
|
55
|
+
* If not provided, common entry points will be searched automatically.
|
|
56
|
+
*/
|
|
57
|
+
entry?: string;
|
|
58
|
+
/**
|
|
59
|
+
* Base directory for resolving relative paths.
|
|
60
|
+
*
|
|
61
|
+
* @default "."
|
|
62
|
+
*/
|
|
63
|
+
dir?: string;
|
|
64
|
+
/**
|
|
65
|
+
* Hook called after the module is loaded to allow for custom processing.
|
|
66
|
+
*
|
|
67
|
+
* You can return a modified version of the module if needed.
|
|
68
|
+
*/
|
|
69
|
+
onLoad?: (module: unknown) => any;
|
|
70
|
+
};
|
|
71
|
+
/**
|
|
72
|
+
* Resolve and import a user server entry module.
|
|
73
|
+
*
|
|
74
|
+
* The loader can work with an explicit `entry` path or fall back to a list of
|
|
75
|
+
* conventional filenames such as `server.ts` and `src/server.ts`. After the
|
|
76
|
+
* module is imported, plain object default exports are unwrapped, a fetch
|
|
77
|
+
* handler is extracted, and a runtime adapter is selected for the current
|
|
78
|
+
* process.
|
|
79
|
+
*/
|
|
80
|
+
declare function loadServerEntry(opts: LoadOptions): Promise<LoadedServerEntry>;
|
|
81
|
+
/**
|
|
82
|
+
* Command-line flags accepted by the `sevok` CLI.
|
|
83
|
+
*/
|
|
84
|
+
type CLIOptions = {
|
|
85
|
+
/** Show help message */help?: boolean; /** Show server and runtime versions */
|
|
86
|
+
version?: boolean; /** Working directory for resolving entry file */
|
|
87
|
+
dir?: string; /** Server entry file to use */
|
|
88
|
+
entry?: string; /** Run in production mode (no watch, no debug) */
|
|
89
|
+
prod?: boolean; /** Serve static files from the specified directory (default: "public") */
|
|
90
|
+
static?: string; /** ES module to preload */
|
|
91
|
+
import?: string; /** Host to bind to (default: all interfaces) */
|
|
92
|
+
hostname?: string; /** (alias to hostname) */
|
|
93
|
+
host?: string; /** Port to listen on (default: "3000") */
|
|
94
|
+
port?: string; /** Enable TLS (HTTPS/HTTP2) */
|
|
95
|
+
tls?: boolean; /** TLS certificate file */
|
|
96
|
+
cert?: string; /** TLS private key file */
|
|
97
|
+
key?: string;
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Programmatic options for invoking the CLI entrypoint.
|
|
101
|
+
*
|
|
102
|
+
* Extends parsed CLI flags with metadata and usage text used by wrappers like
|
|
103
|
+
* the published bin entry.
|
|
104
|
+
*/
|
|
105
|
+
type MainOptions = CLIOptions & {
|
|
106
|
+
/**
|
|
107
|
+
* Explicit argv payload for programmatic invocation.
|
|
108
|
+
*
|
|
109
|
+
* CLI entry files should pass `process.argv.slice(2)` here so `main()` can
|
|
110
|
+
* stay independent from process globals.
|
|
111
|
+
*/
|
|
112
|
+
args?: string[]; /** Optional package metadata for `--version` and help output. */
|
|
113
|
+
meta?: {
|
|
114
|
+
name?: string;
|
|
115
|
+
version?: string;
|
|
116
|
+
description?: string;
|
|
117
|
+
}; /** Optional usage metadata shown in generated help text. */
|
|
118
|
+
usage?: {
|
|
119
|
+
command?: string;
|
|
120
|
+
docs?: string;
|
|
121
|
+
issues?: string;
|
|
122
|
+
};
|
|
123
|
+
};
|
|
124
|
+
/**
|
|
125
|
+
* Main CLI entrypoint.
|
|
126
|
+
*
|
|
127
|
+
* Handles top-level flags, resolves environment files, and decides whether the
|
|
128
|
+
* current process should serve directly or fork a watched child process.
|
|
129
|
+
*/
|
|
130
|
+
declare function main(mainOpts: MainOptions): Promise<void>;
|
|
131
|
+
/**
|
|
132
|
+
* Render the CLI help output.
|
|
133
|
+
*/
|
|
134
|
+
declare function usage(mainOpts: MainOptions): string;
|
|
135
|
+
declare const NO_ENTRY_ERROR = "No server entry or public directory found";
|
|
136
|
+
/**
|
|
137
|
+
* Resolve the user entry module, attach default middleware, and start the
|
|
138
|
+
* runtime adapter-backed server instance.
|
|
139
|
+
*/
|
|
140
|
+
declare function cliServe(cliOpts: CLIOptions): Promise<void>;
|
|
141
|
+
//#endregion
|
|
142
|
+
export { CLIOptions, LoadOptions, LoadedServerEntry, MainOptions, NO_ENTRY_ERROR, cliServe, defaultEntries, defaultExts, loadServerEntry, main, usage };
|