@ngrok/app-server 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +610 -76
- package/dist/build-id-C6sYO9Yp.js +126 -0
- package/dist/build-id-C6sYO9Yp.js.map +1 -0
- package/dist/{build-manifest-8NfD1wnO.js → build-manifest-UDNk81Ce.js} +24 -6
- package/dist/build-manifest-UDNk81Ce.js.map +1 -0
- package/dist/cli.js +45 -25
- package/dist/cli.js.map +1 -1
- package/dist/client.d.ts +141 -0
- package/dist/client.js +326 -0
- package/dist/client.js.map +1 -0
- package/dist/compression-7_gToa8R.js +97 -0
- package/dist/compression-7_gToa8R.js.map +1 -0
- package/dist/create-server-iE1-s6Bi.js +1409 -0
- package/dist/create-server-iE1-s6Bi.js.map +1 -0
- package/dist/{deno-DNRgzHrk.js → deno-aqhikNMG.js} +2 -2
- package/dist/deno-aqhikNMG.js.map +1 -0
- package/dist/entry-DZ3qo7qF.js +116 -0
- package/dist/entry-DZ3qo7qF.js.map +1 -0
- package/dist/entry-DmJEqVfd.d.ts +622 -0
- package/dist/gzip-Doi4wqjX.js +294 -0
- package/dist/gzip-Doi4wqjX.js.map +1 -0
- package/dist/header-hook-Vzw9J9BY.js +159 -0
- package/dist/header-hook-Vzw9J9BY.js.map +1 -0
- package/dist/{index-oSE-tYRW.d.ts → index-Bo5G9LuQ.d.ts} +53 -14
- package/dist/index.d.ts +99 -269
- package/dist/index.js +47 -59
- package/dist/index.js.map +1 -1
- package/dist/listen-options-7TaXjyrk.js.map +1 -1
- package/dist/{load-entry-C03qqmhr.js → load-entry-AfYS_zS9.js} +8 -4
- package/dist/{load-entry-C03qqmhr.js.map → load-entry-AfYS_zS9.js.map} +1 -1
- package/dist/log-BP6xXXZl.js +122 -0
- package/dist/log-BP6xXXZl.js.map +1 -0
- package/dist/node-BFH82eeL.js +333 -0
- package/dist/node-BFH82eeL.js.map +1 -0
- package/dist/node-tBVQPjQv.js +41 -0
- package/dist/node-tBVQPjQv.js.map +1 -0
- package/dist/node-vite.d.ts +5 -4
- package/dist/node-vite.js +2 -17
- package/dist/node.d.ts +23 -4
- package/dist/node.js +2 -2
- package/dist/react-router-vite.d.ts +4 -3
- package/dist/react-router-vite.js +2 -20
- package/dist/react-router.d.ts +1 -1
- package/dist/react-router.js +8 -7
- package/dist/react-router.js.map +1 -1
- package/dist/request-context-BtQ87VYb.js +40 -0
- package/dist/request-context-BtQ87VYb.js.map +1 -0
- package/dist/response-edge-Bc1-C_Cx.js +327 -0
- package/dist/response-edge-Bc1-C_Cx.js.map +1 -0
- package/dist/response-writer-B7FoJjEE.js +289 -0
- package/dist/response-writer-B7FoJjEE.js.map +1 -0
- package/dist/script-hashes-hqUk6kG7.js +53 -0
- package/dist/script-hashes-hqUk6kG7.js.map +1 -0
- package/dist/{serve-Cleo8RMO.js → serve-CDNgThjk.js} +3 -3
- package/dist/{serve-Cleo8RMO.js.map → serve-CDNgThjk.js.map} +1 -1
- package/dist/{start-CINALHxy.js → start-TLIprD74.js} +14 -19
- package/dist/start-TLIprD74.js.map +1 -0
- package/dist/static-files-Beju9riB.js +302 -0
- package/dist/static-files-Beju9riB.js.map +1 -0
- package/dist/tanstack-start-vite.d.ts +6 -5
- package/dist/tanstack-start-vite.js +2 -23
- package/dist/tanstack-start.d.ts +19 -2
- package/dist/tanstack-start.js +5 -14
- package/dist/tanstack-start.js.map +1 -1
- package/dist/{tcp-C-9AmFuM.js → tcp-Dd1Mt6sN.js} +6 -5
- package/dist/{tcp-C-9AmFuM.js.map → tcp-Dd1Mt6sN.js.map} +1 -1
- package/dist/trailing-slash-DX7NB88H.d.ts +36 -0
- package/dist/types-DLYxYS6M.d.ts +392 -0
- package/dist/vercel-vite.d.ts +35 -0
- package/dist/vercel-vite.js +142 -0
- package/dist/vercel-vite.js.map +1 -0
- package/dist/vercel.d.ts +35 -0
- package/dist/vercel.js +89 -0
- package/dist/vercel.js.map +1 -0
- package/dist/vite-B-GfswoH.js +22 -0
- package/dist/vite-B-GfswoH.js.map +1 -0
- package/dist/vite-D4hfj3ph.js +19 -0
- package/dist/vite-D4hfj3ph.js.map +1 -0
- package/dist/vite-DyrhyKEr.js +25 -0
- package/dist/vite-DyrhyKEr.js.map +1 -0
- package/dist/vite-iioAoxSt.js +752 -0
- package/dist/vite-iioAoxSt.js.map +1 -0
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +1 -1
- package/package.json +24 -4
- package/dist/build-manifest-8NfD1wnO.js.map +0 -1
- package/dist/deno-DNRgzHrk.js.map +0 -1
- package/dist/entry-BkdUub2S.js +0 -638
- package/dist/entry-BkdUub2S.js.map +0 -1
- package/dist/log-CsjaKM8U.js +0 -59
- package/dist/log-CsjaKM8U.js.map +0 -1
- package/dist/node-CG7qXuWZ.js +0 -58
- package/dist/node-CG7qXuWZ.js.map +0 -1
- package/dist/node-YWPGmzAk.js +0 -215
- package/dist/node-YWPGmzAk.js.map +0 -1
- package/dist/node-ZMowKZDB.js +0 -3
- package/dist/node-vite.js.map +0 -1
- package/dist/react-router-vite.js.map +0 -1
- package/dist/start-CINALHxy.js.map +0 -1
- package/dist/tanstack-start-vite.js.map +0 -1
- package/dist/types-BfCkS7kQ.d.ts +0 -203
- package/dist/vite-mYZ2Y69u.js +0 -144
- package/dist/vite-mYZ2Y69u.js.map +0 -1
package/dist/tanstack-start.d.ts
CHANGED
|
@@ -1,7 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { a as FrameworkRuntime, h as Mode } from "./types-DLYxYS6M.js";
|
|
2
|
+
import { t as TrailingSlash } from "./trailing-slash-DX7NB88H.js";
|
|
3
|
+
import { AnyRouter, RegisteredRouter } from "@tanstack/react-router";
|
|
4
|
+
/**
|
|
5
|
+
* The `trailingSlash` mode of a TanStack router: the app's registered router
|
|
6
|
+
* by default. A router with no `trailingSlash` has the mode `never`. With no
|
|
7
|
+
* registered router, it is every mode.
|
|
8
|
+
*
|
|
9
|
+
* Use it with `satisfies` on the server's mode. TypeScript then fails when the
|
|
10
|
+
* two modes differ, because different modes make the redirects loop.
|
|
11
|
+
*
|
|
12
|
+
* @example
|
|
13
|
+
* createServer({ plugins: defaultPlugins({ trailingSlash: "never" satisfies RouterTrailingSlash }) });
|
|
14
|
+
*/
|
|
15
|
+
export type RouterTrailingSlash<TRouter extends AnyRouter = RegisteredRouter> = ModeOf<TRouter["options"]["trailingSlash"]>;
|
|
16
|
+
/** A router's `trailingSlash` type as a mode. Why the `any` test: `AnyRouter` has an `any` mode, and a conditional type makes `never` of it. */
|
|
17
|
+
type ModeOf<TOption> = 0 extends 1 & TOption ? TrailingSlash : NonNullable<TOption> extends (infer TMode extends TrailingSlash) ? TMode : TrailingSlash;
|
|
2
18
|
/**
|
|
3
19
|
* The run side of the TanStack Start adapter, for the module of Start's
|
|
4
|
-
* server entry. Start gets the
|
|
20
|
+
* server entry. Start gets the `requestContext()` values as `appServer` in its
|
|
5
21
|
* request context. The server reads the prerendered paths that the Vite plugin
|
|
6
22
|
* recorded.
|
|
7
23
|
*
|
|
@@ -14,4 +30,5 @@ export declare function runtime(serverModule: unknown, { serverFnBase }: {
|
|
|
14
30
|
mode: Mode;
|
|
15
31
|
serverFnBase?: string;
|
|
16
32
|
}): FrameworkRuntime;
|
|
33
|
+
export {};
|
|
17
34
|
//# sourceMappingURL=tanstack-start.d.ts.map
|
package/dist/tanstack-start.js
CHANGED
|
@@ -1,14 +1,8 @@
|
|
|
1
|
+
import { n as requestContextValues } from "./request-context-BtQ87VYb.js";
|
|
2
|
+
|
|
1
3
|
// src/tanstack-start/index.ts
|
|
2
4
|
/** The prefix of Start's server functions when the config sets none. */
|
|
3
5
|
const DEFAULT_SERVER_FN_BASE = "/_serverFn/";
|
|
4
|
-
/**
|
|
5
|
-
* Whether a value is a `Response`. Why not only `instanceof`: on Node, the
|
|
6
|
-
* listener replaces the global `Response`, but `fetch()` still returns the
|
|
7
|
-
* original type.
|
|
8
|
-
*/
|
|
9
|
-
function isResponse(value) {
|
|
10
|
-
return value instanceof Response || Object.prototype.toString.call(value) === "[object Response]";
|
|
11
|
-
}
|
|
12
6
|
/** Whether a module's default export is a TanStack Start server entry. */
|
|
13
7
|
function startServerEntry(module) {
|
|
14
8
|
if (typeof module !== "object" || module == null) return;
|
|
@@ -18,13 +12,13 @@ function startServerEntry(module) {
|
|
|
18
12
|
if (typeof fetch !== "function") return;
|
|
19
13
|
return { fetch: async (request, options) => {
|
|
20
14
|
const response = await Reflect.apply(fetch, entry, [request, options]);
|
|
21
|
-
if (!
|
|
15
|
+
if (!(response instanceof Response)) throw new TypeError("The TanStack Start server entry did not return a Response.");
|
|
22
16
|
return response;
|
|
23
17
|
} };
|
|
24
18
|
}
|
|
25
19
|
/**
|
|
26
20
|
* The run side of the TanStack Start adapter, for the module of Start's
|
|
27
|
-
* server entry. Start gets the
|
|
21
|
+
* server entry. Start gets the `requestContext()` values as `appServer` in its
|
|
28
22
|
* request context. The server reads the prerendered paths that the Vite plugin
|
|
29
23
|
* recorded.
|
|
30
24
|
*
|
|
@@ -39,10 +33,7 @@ function runtime(serverModule, { serverFnBase = DEFAULT_SERVER_FN_BASE }) {
|
|
|
39
33
|
return {
|
|
40
34
|
name: "tanstack-start",
|
|
41
35
|
isDataRequest: (path) => path.startsWith(serverFnBase),
|
|
42
|
-
fetch: async (request, context) => entry.fetch(request, { context: { appServer:
|
|
43
|
-
requestId: context.var.requestId,
|
|
44
|
-
logger: context.var.logger
|
|
45
|
-
} } })
|
|
36
|
+
fetch: async (request, context) => entry.fetch(request, { context: { appServer: requestContextValues(context) } })
|
|
46
37
|
};
|
|
47
38
|
}
|
|
48
39
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tanstack-start.js","names":[],"sources":["../src/tanstack-start/index.ts"],"sourcesContent":["import type { FrameworkRuntime, Mode } from \"../core/types.js\";\n\n/** The prefix of Start's server functions when the config sets none. */\nconst DEFAULT_SERVER_FN_BASE = \"/_serverFn/\";\n\n/** The part of a TanStack Start server entry that the adapter calls. */\ntype StartServerEntry = {\n\tfetch: (\n\t\trequest: Request,\n\t\toptions?: { context?: Record<string, unknown> },\n\t) => Response | Promise<Response>;\n};\n\n
|
|
1
|
+
{"version":3,"file":"tanstack-start.js","names":[],"sources":["../src/tanstack-start/index.ts"],"sourcesContent":["import type { AnyRouter, RegisteredRouter } from \"@tanstack/react-router\";\nimport type { TrailingSlash } from \"../core/plugins/trailing-slash.js\";\nimport { requestContextValues } from \"../core/request-context.js\";\nimport type { FrameworkRuntime, Mode } from \"../core/types.js\";\n\n/**\n * The `trailingSlash` mode of a TanStack router: the app's registered router\n * by default. A router with no `trailingSlash` has the mode `never`. With no\n * registered router, it is every mode.\n *\n * Use it with `satisfies` on the server's mode. TypeScript then fails when the\n * two modes differ, because different modes make the redirects loop.\n *\n * @example\n * createServer({ plugins: defaultPlugins({ trailingSlash: \"never\" satisfies RouterTrailingSlash }) });\n */\nexport type RouterTrailingSlash<TRouter extends AnyRouter = RegisteredRouter> = ModeOf<\n\tTRouter[\"options\"][\"trailingSlash\"]\n>;\n\n/** A router's `trailingSlash` type as a mode. Why the `any` test: `AnyRouter` has an `any` mode, and a conditional type makes `never` of it. */\ntype ModeOf<TOption> = 0 extends 1 & TOption\n\t? TrailingSlash\n\t: NonNullable<TOption> extends infer TMode extends TrailingSlash\n\t\t? TMode\n\t\t: TrailingSlash;\n\n/** The prefix of Start's server functions when the config sets none. */\nconst DEFAULT_SERVER_FN_BASE = \"/_serverFn/\";\n\n/** The part of a TanStack Start server entry that the adapter calls. */\ntype StartServerEntry = {\n\tfetch: (\n\t\trequest: Request,\n\t\toptions?: { context?: Record<string, unknown> },\n\t) => Response | Promise<Response>;\n};\n\n/** Whether a module's default export is a TanStack Start server entry. */\nfunction startServerEntry(module: unknown): StartServerEntry | undefined {\n\tif (typeof module !== \"object\" || module == null) {\n\t\treturn undefined;\n\t}\n\tconst entry: unknown = Reflect.get(module, \"default\");\n\tif (typeof entry !== \"object\" || entry == null || !(\"fetch\" in entry)) {\n\t\treturn undefined;\n\t}\n\tconst { fetch } = entry;\n\tif (typeof fetch !== \"function\") {\n\t\treturn undefined;\n\t}\n\treturn {\n\t\tfetch: async (request, options) => {\n\t\t\tconst response: unknown = await Reflect.apply(fetch, entry, [request, options]);\n\t\t\tif (!(response instanceof Response)) {\n\t\t\t\tthrow new TypeError(\"The TanStack Start server entry did not return a Response.\");\n\t\t\t}\n\t\t\treturn response;\n\t\t},\n\t};\n}\n\n/**\n * The run side of the TanStack Start adapter, for the module of Start's\n * server entry. Start gets the `requestContext()` values as `appServer` in its\n * request context. The server reads the prerendered paths that the Vite plugin\n * recorded.\n *\n * @param info.serverFnBase - The prefix of Start's server functions, `TSS_SERVER_FN_BASE`. The entry that the Vite plugin generates sets it.\n *\n * @example\n * const framework = runtime(await import(\"virtual:tanstack-start-server-entry\"), { mode: \"production\" });\n */\nexport function runtime(\n\tserverModule: unknown,\n\t{ serverFnBase = DEFAULT_SERVER_FN_BASE }: { mode: Mode; serverFnBase?: string },\n): FrameworkRuntime {\n\tconst entry = startServerEntry(serverModule);\n\tif (entry == null) {\n\t\tthrow new Error(\"The server module has no TanStack Start server entry as its default export.\");\n\t}\n\treturn {\n\t\tname: \"tanstack-start\",\n\t\tisDataRequest: (path) => path.startsWith(serverFnBase),\n\t\tfetch: async (request, context) =>\n\t\t\tentry.fetch(request, {\n\t\t\t\tcontext: {\n\t\t\t\t\tappServer: requestContextValues(context),\n\t\t\t\t},\n\t\t\t}),\n\t};\n}\n"],"mappings":";;;;AA4BA,MAAM,yBAAyB;;AAW/B,SAAS,iBAAiB,QAA+C;CACxE,IAAI,OAAO,WAAW,YAAY,UAAU,MAC3C;CAED,MAAM,QAAiB,QAAQ,IAAI,QAAQ,SAAS;CACpD,IAAI,OAAO,UAAU,YAAY,SAAS,QAAQ,EAAE,WAAW,QAC9D;CAED,MAAM,EAAE,UAAU;CAClB,IAAI,OAAO,UAAU,YACpB;CAED,OAAO,EACN,OAAO,OAAO,SAAS,YAAY;EAClC,MAAM,WAAoB,MAAM,QAAQ,MAAM,OAAO,OAAO,CAAC,SAAS,OAAO,CAAC;EAC9E,IAAI,EAAE,oBAAoB,WACzB,MAAM,IAAI,UAAU,4DAA4D;EAEjF,OAAO;CACR,EACD;AACD;;;;;;;;;;;;AAaA,SAAgB,QACf,cACA,EAAE,eAAe,0BACE;CACnB,MAAM,QAAQ,iBAAiB,YAAY;CAC3C,IAAI,SAAS,MACZ,MAAM,IAAI,MAAM,6EAA6E;CAE9F,OAAO;EACN,MAAM;EACN,gBAAgB,SAAS,KAAK,WAAW,YAAY;EACrD,OAAO,OAAO,SAAS,YACtB,MAAM,MAAM,SAAS,EACpB,SAAS,EACR,WAAW,qBAAqB,OAAO,EACxC,EACD,CAAC;CACH;AACD"}
|
|
@@ -24,18 +24,19 @@ function parsePort(value) {
|
|
|
24
24
|
function tcp({ port, host, idleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS } = {}) {
|
|
25
25
|
return {
|
|
26
26
|
name: "tcp",
|
|
27
|
-
start: async (fetch) => {
|
|
27
|
+
start: async (fetch, { trustForwardedProto = false } = {}) => {
|
|
28
28
|
const options = {
|
|
29
29
|
port: port ?? (process.env.PORT == null ? 3e3 : parsePort(process.env.PORT)),
|
|
30
30
|
hostname: host ?? (process.env.HOST || void 0),
|
|
31
|
-
idleTimeoutMs
|
|
31
|
+
idleTimeoutMs,
|
|
32
|
+
trustForwardedProto
|
|
32
33
|
};
|
|
33
34
|
if ("Bun" in globalThis) return (await import("./bun-BCz6K_Xv.js")).listen(fetch, options);
|
|
34
|
-
if ("Deno" in globalThis) return (await import("./deno-
|
|
35
|
-
return (await import("./node-
|
|
35
|
+
if ("Deno" in globalThis) return (await import("./deno-aqhikNMG.js")).listen(fetch, options);
|
|
36
|
+
return (await import("./node-tBVQPjQv.js")).listen(fetch, options);
|
|
36
37
|
}
|
|
37
38
|
};
|
|
38
39
|
}
|
|
39
40
|
|
|
40
41
|
export { tcp as n, parsePort as t };
|
|
41
|
-
//# sourceMappingURL=tcp-
|
|
42
|
+
//# sourceMappingURL=tcp-Dd1Mt6sN.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tcp-
|
|
1
|
+
{"version":3,"file":"tcp-Dd1Mt6sN.js","names":[],"sources":["../src/node/tcp.ts"],"sourcesContent":["import type { Listener } from \"../core/types.js\";\n\n/** Above the ngrok edge's 90 s idle pool, so the edge never reuses a socket that the server is closing. */\nconst DEFAULT_IDLE_TIMEOUT_MS = 95_000;\n\n/** Options for {@link tcp}. */\nexport type TcpOptions = {\n\t/** @default the `PORT` environment variable, else 3000 */\n\tport?: number;\n\t/** @default the `HOST` environment variable, else every interface */\n\thost?: string;\n\t/** @default 95000 */\n\tidleTimeoutMs?: number;\n};\n\n/**\n * Reads a port number. A value that is not an integer from 0 to 65535 throws,\n * so a bad `PORT` stops startup.\n *\n * @example\n * parsePort(\"8080\"); // => 8080\n */\nexport function parsePort(value: string): number {\n\tconst port = Number(value);\n\tif (value.trim() === \"\" || !Number.isInteger(port) || port < 0 || port > 65_535) {\n\t\tthrow new Error(`PORT must be an integer from 0 to 65535, not \"${value}\".`);\n\t}\n\treturn port;\n}\n\n/**\n * The default listener: a TCP port, served by the runtime's own HTTP server\n * (`node:http` on Node, `Bun.serve` on Bun, `Deno.serve` on Deno). It reads\n * `PORT` and `HOST` when it starts.\n *\n * @example\n * createServer({ listeners: [tcp({ port: 8080 })] });\n */\nexport function tcp({\n\tport,\n\thost,\n\tidleTimeoutMs = DEFAULT_IDLE_TIMEOUT_MS,\n}: TcpOptions = {}): Listener {\n\treturn {\n\t\tname: \"tcp\",\n\t\tstart: async (fetch, { trustForwardedProto = false } = {}) => {\n\t\t\tconst options = {\n\t\t\t\tport: port ?? (process.env.PORT == null ? 3000 : parsePort(process.env.PORT)),\n\t\t\t\thostname: host ?? (process.env.HOST || undefined),\n\t\t\t\tidleTimeoutMs,\n\t\t\t\ttrustForwardedProto,\n\t\t\t};\n\t\t\tif (\"Bun\" in globalThis) {\n\t\t\t\treturn (await import(\"./runtimes/bun.js\")).listen(fetch, options);\n\t\t\t}\n\t\t\tif (\"Deno\" in globalThis) {\n\t\t\t\treturn (await import(\"./runtimes/deno.js\")).listen(fetch, options);\n\t\t\t}\n\t\t\treturn (await import(\"./runtimes/node.js\")).listen(fetch, options);\n\t\t},\n\t};\n}\n"],"mappings":";;AAGA,MAAM,0BAA0B;;;;;;;;AAmBhC,SAAgB,UAAU,OAAuB;CAChD,MAAM,OAAO,OAAO,KAAK;CACzB,IAAI,MAAM,KAAK,MAAM,MAAM,CAAC,OAAO,UAAU,IAAI,KAAK,OAAO,KAAK,OAAO,OACxE,MAAM,IAAI,MAAM,iDAAiD,MAAM,GAAG;CAE3E,OAAO;AACR;;;;;;;;;AAUA,SAAgB,IAAI,EACnB,MACA,MACA,gBAAgB,4BACD,CAAC,GAAa;CAC7B,OAAO;EACN,MAAM;EACN,OAAO,OAAO,OAAO,EAAE,sBAAsB,UAAU,CAAC,MAAM;GAC7D,MAAM,UAAU;IACf,MAAM,SAAS,QAAQ,IAAI,QAAQ,OAAO,MAAO,UAAU,QAAQ,IAAI,IAAI;IAC3E,UAAU,SAAS,QAAQ,IAAI,QAAQ;IACvC;IACA;GACD;GACA,IAAI,SAAS,YACZ,QAAQ,MAAM,OAAO,qBAAoB,CAAE,OAAO,OAAO,OAAO;GAEjE,IAAI,UAAU,YACb,QAAQ,MAAM,OAAO,sBAAqB,CAAE,OAAO,OAAO,OAAO;GAElE,QAAQ,MAAM,OAAO,sBAAqB,CAAE,OAAO,OAAO,OAAO;EAClE;CACD;AACD"}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { g as Plugin } from "./types-DLYxYS6M.js";
|
|
2
|
+
/**
|
|
3
|
+
* How a page URL ends:
|
|
4
|
+
*
|
|
5
|
+
* - `never`: with no trailing slash, such as `/docs/button`.
|
|
6
|
+
* - `always`: with a trailing slash, such as `/docs/button/`.
|
|
7
|
+
* - `preserve`: as the request has it. The server sends no redirect.
|
|
8
|
+
*/
|
|
9
|
+
type TrailingSlash = "never" | "always" | "preserve";
|
|
10
|
+
/** Options for {@link trailingSlash}. */
|
|
11
|
+
type TrailingSlashOptions = {
|
|
12
|
+
mode: TrailingSlash;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Sends a 308 from a page URL to the same URL in `mode`, so each page has one
|
|
16
|
+
* URL. It applies to rendered and prerendered pages, because the server cannot
|
|
17
|
+
* tell which paths have a route. The redirect keeps the query string.
|
|
18
|
+
*
|
|
19
|
+
* It sends no redirect for `/`, a method other than GET or HEAD, a data
|
|
20
|
+
* request of the framework, a path that one of the app's own Hono routes
|
|
21
|
+
* matches, such as `app.get("/livez")`, or a path that already has the
|
|
22
|
+
* mode's form. `always` adds no slash to a file in the client build, such as
|
|
23
|
+
* `/LICENSE`, or to a path whose last segment has a dot, such as `/llms.txt`.
|
|
24
|
+
*
|
|
25
|
+
* Set the same mode in the framework's router when it has one. Else the two
|
|
26
|
+
* redirects loop: the server sends `/x` to `/x/`, and the router sends `/x/`
|
|
27
|
+
* back to `/x`. For TanStack Start, check the mode against the router with
|
|
28
|
+
* `RouterTrailingSlash` from `@ngrok/app-server/tanstack-start`. React Router
|
|
29
|
+
* has no trailing-slash option, so it answers both forms itself.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* createServer({ plugins: defaultPlugins({ trailingSlash: "always" }) });
|
|
33
|
+
*/
|
|
34
|
+
declare function trailingSlash({ mode }: TrailingSlashOptions): Plugin;
|
|
35
|
+
export { TrailingSlashOptions as n, trailingSlash as r, TrailingSlash as t };
|
|
36
|
+
//# sourceMappingURL=trailing-slash-DX7NB88H.d.ts.map
|
|
@@ -0,0 +1,392 @@
|
|
|
1
|
+
import { Context, MiddlewareHandler } from "hono";
|
|
2
|
+
/**
|
|
3
|
+
* What the server and a listener that writes each response itself share for
|
|
4
|
+
* one request. The listener makes one for each request and gives it as the
|
|
5
|
+
* `edge` binding. The server then runs the header hooks on a list of the
|
|
6
|
+
* headers, so it copies no response for them. The listener:
|
|
7
|
+
*
|
|
8
|
+
* - writes {@link ResponseEdge.headersFor} in place of the headers of the response
|
|
9
|
+
* - adds each body byte that it writes to {@link ResponseEdge.bytes}
|
|
10
|
+
* - gives an error that stops the response to {@link ResponseEdge.fail}
|
|
11
|
+
* - calls {@link ResponseEdge.close} once, when the response ends or its client goes away
|
|
12
|
+
*
|
|
13
|
+
* @example
|
|
14
|
+
* const edge = new ResponseEdge();
|
|
15
|
+
* const response = await fetch(request, { remoteAddress, edge });
|
|
16
|
+
* outgoing.writeHead(response.status, edge.headersFor(response) ?? [...response.headers].flat());
|
|
17
|
+
*/
|
|
18
|
+
declare class ResponseEdge {
|
|
19
|
+
#private;
|
|
20
|
+
/** The body bytes that the listener gave to its socket. */
|
|
21
|
+
bytes: number;
|
|
22
|
+
/**
|
|
23
|
+
* Gives the edge to the request of `logger`, and gives `true`, the first
|
|
24
|
+
* time only. The server calls it when a request starts. Why once: a
|
|
25
|
+
* request that the app sends through itself again with the same bindings
|
|
26
|
+
* must change its own response.
|
|
27
|
+
*/
|
|
28
|
+
claim(logger: RequestLogger): boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Keeps `headers`, the headers of the response after each header hook, and
|
|
31
|
+
* `base`, its headers before the hooks. The server calls it.
|
|
32
|
+
*/
|
|
33
|
+
useHeaders(base: readonly string[], headers: string[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* The headers to write for `response`: lowercase names and their values in
|
|
36
|
+
* turn, as Node's `writeHead` takes them. They are the headers after the
|
|
37
|
+
* hooks, with each change that the headers of `response` have from the
|
|
38
|
+
* response that the hooks ran on. Why: Hono answers HEAD with a copy that
|
|
39
|
+
* has no body, and a wrapper of the app's `fetch` can change the headers or
|
|
40
|
+
* return a copy. It gives `undefined` when the server kept no headers.
|
|
41
|
+
*/
|
|
42
|
+
headersFor(response: Response): string[] | undefined;
|
|
43
|
+
/**
|
|
44
|
+
* Calls `report` once, when the response ends or its client goes away. It
|
|
45
|
+
* calls it at once when that happened already. A throw from `report` never
|
|
46
|
+
* reaches the listener.
|
|
47
|
+
*/
|
|
48
|
+
onSent(report: (sent: SentResponse) => void): void;
|
|
49
|
+
/** Logs `error`, which stopped the response, with the logger of the request. */
|
|
50
|
+
fail(error: unknown): void;
|
|
51
|
+
/**
|
|
52
|
+
* Reports what went out, once: the status and the headers that the
|
|
53
|
+
* listener sent, the bytes, and whether the body stopped before its end.
|
|
54
|
+
* `head` is the flat list that the listener gave `writeHead`.
|
|
55
|
+
*/
|
|
56
|
+
close(status: number, aborted: boolean, head: string[]): void;
|
|
57
|
+
}
|
|
58
|
+
/** A log level the server writes. */
|
|
59
|
+
type LogLevel = "debug" | "info" | "warn" | "error";
|
|
60
|
+
/**
|
|
61
|
+
* Where the server writes log lines. Pass the app's own formatter, or use
|
|
62
|
+
* {@link jsonSink}. Attribute names are flat and dotted, such as `http.method`.
|
|
63
|
+
*/
|
|
64
|
+
type LogSink = {
|
|
65
|
+
log: (level: LogLevel, message: string, attributes: Readonly<Record<string, unknown>>) => void;
|
|
66
|
+
};
|
|
67
|
+
/** The logger for one request. Each line carries the request ID, method, and path. */
|
|
68
|
+
type RequestLogger = Record<LogLevel, (message: string, attributes?: Readonly<Record<string, unknown>>) => void>;
|
|
69
|
+
/** What {@link requestContext} gives for the request that runs. */
|
|
70
|
+
type RequestContext = {
|
|
71
|
+
/** The request ID, when the `requestId` plugin runs. */
|
|
72
|
+
requestId: string | undefined;
|
|
73
|
+
/** The request's logger. Its lines carry the request ID. */
|
|
74
|
+
logger: RequestLogger;
|
|
75
|
+
/** The nonce for the request's inline scripts, when the `contentSecurityPolicy` plugin runs. */
|
|
76
|
+
cspNonce: string | undefined;
|
|
77
|
+
/** The client's IP address, from `X-Forwarded-For` when `trustedProxyHops` is set, else from the socket. */
|
|
78
|
+
clientAddress: string | undefined;
|
|
79
|
+
};
|
|
80
|
+
/** The server mode. */
|
|
81
|
+
type Mode = "production" | "development";
|
|
82
|
+
/**
|
|
83
|
+
* The run side of a framework adapter: the framework that answers each
|
|
84
|
+
* request that no plugin or route answers.
|
|
85
|
+
*/
|
|
86
|
+
type FrameworkRuntime = {
|
|
87
|
+
/** A name for logs and errors. */
|
|
88
|
+
name: string;
|
|
89
|
+
/** Renders one request. */
|
|
90
|
+
fetch: (request: Request, context: Context<AppServerEnv>) => Promise<Response>;
|
|
91
|
+
/**
|
|
92
|
+
* The client build, when the framework knows it. The entry that the Vite
|
|
93
|
+
* plugin generates gives it instead.
|
|
94
|
+
*/
|
|
95
|
+
clientDirectory?: string;
|
|
96
|
+
/**
|
|
97
|
+
* The URL paths that the build prerenders, when the framework knows them.
|
|
98
|
+
* Else production reads the paths that the Vite plugin captured, and
|
|
99
|
+
* development has none to read.
|
|
100
|
+
*/
|
|
101
|
+
prerenderedPaths?: readonly string[];
|
|
102
|
+
/** Whether a URL path is a data request, such as a React Router `.data` file. */
|
|
103
|
+
isDataRequest?: (path: string) => boolean;
|
|
104
|
+
/** Content types that `mime` does not know, by file extension, such as `{ ".data": "text/x-script" }`. */
|
|
105
|
+
contentTypes?: Readonly<Record<string, string>>;
|
|
106
|
+
};
|
|
107
|
+
/** Makes the run side of a framework adapter from the framework's server module. */
|
|
108
|
+
type FrameworkRuntimeFactory = (serverModule: unknown, info: {
|
|
109
|
+
mode: Mode;
|
|
110
|
+
}) => FrameworkRuntime;
|
|
111
|
+
/** What a host knows about a file under the client build. */
|
|
112
|
+
type FileInfo = {
|
|
113
|
+
kind: "file" | "directory";
|
|
114
|
+
/** The size in bytes. */
|
|
115
|
+
size: number;
|
|
116
|
+
mtimeMs: number;
|
|
117
|
+
};
|
|
118
|
+
/** A range of bytes in a file. `start` and `end` are both inclusive. */
|
|
119
|
+
type ByteRange = {
|
|
120
|
+
start: number;
|
|
121
|
+
end: number;
|
|
122
|
+
};
|
|
123
|
+
/**
|
|
124
|
+
* The files of the client build. Each path is a URL path that the static
|
|
125
|
+
* stages checked: it starts with `/`, and it has no `..`, no `//`, and no
|
|
126
|
+
* `\`.
|
|
127
|
+
*/
|
|
128
|
+
type StaticFiles = {
|
|
129
|
+
/** What is at `path`, or `undefined` when nothing is there. */
|
|
130
|
+
stat: (path: string) => Promise<FileInfo | undefined>;
|
|
131
|
+
/**
|
|
132
|
+
* The bytes of the file at `path`. With `range`, only the bytes from
|
|
133
|
+
* `start` to `end`, both inclusive. A host must honor `range`, because the
|
|
134
|
+
* static stages answer a `Range` request with these bytes. Open the file on
|
|
135
|
+
* the first read. Why: a stage can drop a response that no one reads.
|
|
136
|
+
*/
|
|
137
|
+
open: (path: string, range?: ByteRange) => Promise<ReadableStream<Uint8Array>>;
|
|
138
|
+
/**
|
|
139
|
+
* A copy whose `stat` answers from a list of the files that it reads once.
|
|
140
|
+
* The production server uses it, because the client build does not change
|
|
141
|
+
* while the server runs. Without it, each lookup calls `stat`.
|
|
142
|
+
*/
|
|
143
|
+
snapshot?: () => Promise<StaticFiles>;
|
|
144
|
+
};
|
|
145
|
+
/** Request-scoped storage, such as `AsyncLocalStorage`. */
|
|
146
|
+
type RequestStore = {
|
|
147
|
+
/** Runs `work` with `value` as the stored value. */
|
|
148
|
+
run: <Result>(value: Context<AppServerEnv>, work: () => Result) => Result;
|
|
149
|
+
/** The stored value of the request that runs, else `undefined`. */
|
|
150
|
+
get: () => Context<AppServerEnv> | undefined;
|
|
151
|
+
};
|
|
152
|
+
/** What went out for a response, when it ends or its client goes away. */
|
|
153
|
+
type SentResponse = {
|
|
154
|
+
/**
|
|
155
|
+
* The status that went out. It differs from the status of the response
|
|
156
|
+
* when a listener could not send the response, such as a 500 for a header
|
|
157
|
+
* value that it cannot write.
|
|
158
|
+
*/
|
|
159
|
+
status: number;
|
|
160
|
+
/**
|
|
161
|
+
* The headers that went out with `status`, after each header hook. Read
|
|
162
|
+
* them here, not from `c.res`, which can lack the changes of the hooks: on
|
|
163
|
+
* Node.js and Vercel the hooks change the list that the listener writes,
|
|
164
|
+
* and Bun empties the headers of a response that it sent.
|
|
165
|
+
*/
|
|
166
|
+
headers: Pick<ResponseHeaders, "get" | "has">;
|
|
167
|
+
/**
|
|
168
|
+
* The body bytes that went out, after compression. When `aborted` is
|
|
169
|
+
* true, the client can have got fewer.
|
|
170
|
+
*/
|
|
171
|
+
bytes: number;
|
|
172
|
+
/** Whether the body stopped before its end, such as when the client went away or the body failed. */
|
|
173
|
+
aborted: boolean;
|
|
174
|
+
};
|
|
175
|
+
/** How a long-lived host stops. A serverless host has none. */
|
|
176
|
+
type Lifecycle = {
|
|
177
|
+
/**
|
|
178
|
+
* Calls `stop` once when the host must stop, such as on `SIGTERM`. The host
|
|
179
|
+
* exits when `stop` settles.
|
|
180
|
+
*/
|
|
181
|
+
onStop: (stop: () => Promise<void>) => void;
|
|
182
|
+
};
|
|
183
|
+
/** The run side of a host adapter: where the server runs. */
|
|
184
|
+
type HostRuntime = {
|
|
185
|
+
/** A name for logs and errors. */
|
|
186
|
+
name: string;
|
|
187
|
+
/** The files of the client build at `clientDirectory`, a file path or a `file:` URL. */
|
|
188
|
+
files: (clientDirectory: string) => StaticFiles;
|
|
189
|
+
/**
|
|
190
|
+
* The listeners when the app sets none. A serverless host has none: it
|
|
191
|
+
* calls the entry's `fetch` for each request.
|
|
192
|
+
*/
|
|
193
|
+
listeners?: () => readonly Listener[];
|
|
194
|
+
/** The storage for {@link requestContext}. Without it, `requestContext()` gives `undefined`. */
|
|
195
|
+
storage?: RequestStore;
|
|
196
|
+
/**
|
|
197
|
+
* Gzips a byte stream and flushes after each chunk. Without it,
|
|
198
|
+
* `streamingCompress` sends each response as it is.
|
|
199
|
+
*/
|
|
200
|
+
gzip?: (source: ReadableStream<Uint8Array>) => ReadableStream<Uint8Array>;
|
|
201
|
+
lifecycle?: Lifecycle;
|
|
202
|
+
};
|
|
203
|
+
/**
|
|
204
|
+
* What a listener passes to the app with each request. A host can add its own
|
|
205
|
+
* values, such as Node's request and response.
|
|
206
|
+
*/
|
|
207
|
+
type ListenerBindings = {
|
|
208
|
+
/** The client's IP address, when the runtime knows it. */
|
|
209
|
+
remoteAddress?: string | undefined;
|
|
210
|
+
/**
|
|
211
|
+
* Given by a listener that writes each response itself, such as the node
|
|
212
|
+
* listener. See {@link ResponseEdge}.
|
|
213
|
+
*/
|
|
214
|
+
edge?: ResponseEdge | undefined;
|
|
215
|
+
[binding: string]: unknown;
|
|
216
|
+
};
|
|
217
|
+
/** The Hono bindings of an app server: the listener's values and the framework. */
|
|
218
|
+
type ServerBindings = ListenerBindings & {
|
|
219
|
+
framework: FrameworkRuntime;
|
|
220
|
+
};
|
|
221
|
+
/** The Hono environment of an app server. */
|
|
222
|
+
type AppServerEnv = {
|
|
223
|
+
Bindings: ServerBindings;
|
|
224
|
+
Variables: {
|
|
225
|
+
/** The request ID, set by the `requestId` plugin. */
|
|
226
|
+
requestId?: string;
|
|
227
|
+
logger: RequestLogger;
|
|
228
|
+
/** The nonce for the request's inline scripts, set by the `contentSecurityPolicy` plugin. */
|
|
229
|
+
cspNonce?: string;
|
|
230
|
+
/**
|
|
231
|
+
* The URL path of the client build's HTML file that the response sends,
|
|
232
|
+
* such as `/about/index.html`. The static stages set it, for a 304 too.
|
|
233
|
+
*/
|
|
234
|
+
staticDocument?: string;
|
|
235
|
+
/**
|
|
236
|
+
* The hashes of the inline scripts of an HTML file that the dev server
|
|
237
|
+
* sends as it is on disk, such as a file of Vite's public directory. The
|
|
238
|
+
* dev server stage sets it, for a 304 too.
|
|
239
|
+
*/
|
|
240
|
+
documentScriptHashes?: readonly string[];
|
|
241
|
+
/** The client's IP address. See `trustedProxyHops` on `createServer`. */
|
|
242
|
+
clientAddress?: string | undefined;
|
|
243
|
+
/** Attributes that each log line of the request carries, such as the trace IDs from the `requestId` plugin. */
|
|
244
|
+
logAttributes?: Readonly<Record<string, unknown>>;
|
|
245
|
+
/**
|
|
246
|
+
* The `etagPart` of each plugin that the request passed, in order. The
|
|
247
|
+
* static stages add them to each file's ETag. The server sets this list.
|
|
248
|
+
*/
|
|
249
|
+
etagParts?: readonly string[];
|
|
250
|
+
/**
|
|
251
|
+
* Whether a stage that the request passed changes the bytes of an HTML
|
|
252
|
+
* body, as `runtimeEnv` does. The stage sets it before its `next()`.
|
|
253
|
+
* The static stages then send an HTML file as it is on disk, not its
|
|
254
|
+
* compressed copy, so the stage can change it.
|
|
255
|
+
*/
|
|
256
|
+
rewritesHtml?: boolean;
|
|
257
|
+
/** The header hook of each stage that the request passed, in order. See {@link HeaderHook}. */
|
|
258
|
+
headerHooks?: HeaderHook[];
|
|
259
|
+
/** The reports of `onResponseSent` for the request. The server sets this list. */
|
|
260
|
+
sentReports?: ((sent: SentResponse) => void)[];
|
|
261
|
+
};
|
|
262
|
+
};
|
|
263
|
+
/** The headers of a response, for a {@link HeaderHook}. */
|
|
264
|
+
type ResponseHeaders = {
|
|
265
|
+
get: (name: string) => string | null;
|
|
266
|
+
has: (name: string) => boolean;
|
|
267
|
+
set: (name: string, value: string) => undefined;
|
|
268
|
+
append: (name: string, value: string) => undefined;
|
|
269
|
+
delete: (name: string) => undefined;
|
|
270
|
+
};
|
|
271
|
+
/**
|
|
272
|
+
* A change to the headers of a response, from a stage that runs before the
|
|
273
|
+
* response. In an app server, it changes the head once, where the response
|
|
274
|
+
* leaves, after the code that each stage runs after its `next()`: the hook of
|
|
275
|
+
* an inner stage runs first, so an outer stage has the last word. A hook that
|
|
276
|
+
* throws gives a 500, as a stage that throws does. A dev server middleware
|
|
277
|
+
* that sends its own response runs the hooks before it sends the head.
|
|
278
|
+
*
|
|
279
|
+
* The static stages and `streamingCompress` also run the hooks on a view of
|
|
280
|
+
* the headers, to read the `Cache-Control` that leaves. So a hook can run two
|
|
281
|
+
* or three times for one request: each run must give the same headers and do
|
|
282
|
+
* nothing else, such as log, count, or store a value. A view run can come
|
|
283
|
+
* before the code that a stage runs after its `next()`, and a throw in it
|
|
284
|
+
* changes nothing.
|
|
285
|
+
*/
|
|
286
|
+
type HeaderHook = (headers: ResponseHeaders) => undefined;
|
|
287
|
+
/** The request handler that a listener calls. */
|
|
288
|
+
type FetchHandler = (request: Request, bindings: ListenerBindings) => Response | Promise<Response>;
|
|
289
|
+
/** What a plugin learns at startup, before the first request. */
|
|
290
|
+
type SetupInfo = {
|
|
291
|
+
/** The files of the client build. */
|
|
292
|
+
files: StaticFiles;
|
|
293
|
+
/** The headers of each prerendered file, by URL path, that the Vite plugin captured. */
|
|
294
|
+
capturedHeaders: ReadonlyMap<string, Readonly<Record<string, string>>>;
|
|
295
|
+
/**
|
|
296
|
+
* The base64 `SHA-256` of each inline script of each HTML file in the client
|
|
297
|
+
* build, by the file's URL path, that the Vite plugin recorded.
|
|
298
|
+
*/
|
|
299
|
+
scriptHashes: ReadonlyMap<string, readonly string[]>;
|
|
300
|
+
/**
|
|
301
|
+
* The ID of the client build that the Vite plugin derived. It is
|
|
302
|
+
* `undefined` in development and for a build with no build manifest.
|
|
303
|
+
*/
|
|
304
|
+
buildId: string | undefined;
|
|
305
|
+
/** Whether a URL path is a data request of the framework. */
|
|
306
|
+
isDataRequest: (path: string) => boolean;
|
|
307
|
+
/** Content types of the framework's files that `mime` does not know, by file extension. */
|
|
308
|
+
contentTypes: Readonly<Record<string, string>>;
|
|
309
|
+
/** The host's gzip stream, when it has one. */
|
|
310
|
+
gzip: ((source: ReadableStream<Uint8Array>) => ReadableStream<Uint8Array>) | undefined;
|
|
311
|
+
logger: LogSink;
|
|
312
|
+
} & ({
|
|
313
|
+
mode: "production";
|
|
314
|
+
/** The URL paths that the build prerendered. */
|
|
315
|
+
prerenderedPaths: readonly string[];
|
|
316
|
+
} | {
|
|
317
|
+
mode: "development";
|
|
318
|
+
/** The dev server as a pipeline stage. It serves source modules, HMR, and CSS. */
|
|
319
|
+
devServer: MiddlewareHandler<AppServerEnv>;
|
|
320
|
+
/**
|
|
321
|
+
* The URL paths that the build will prerender, or `undefined` when the
|
|
322
|
+
* framework finds them only during the build, as TanStack Start does.
|
|
323
|
+
*/
|
|
324
|
+
prerenderedPaths: readonly string[] | undefined;
|
|
325
|
+
});
|
|
326
|
+
/**
|
|
327
|
+
* One step of the request pipeline. Plugins run in list order, so the order is
|
|
328
|
+
* the contract.
|
|
329
|
+
*
|
|
330
|
+
* @example
|
|
331
|
+
* const livez: Plugin = {
|
|
332
|
+
* name: "livez",
|
|
333
|
+
* middleware: async (c, next) => (c.req.path === "/livez" ? c.text("ok") : next()),
|
|
334
|
+
* };
|
|
335
|
+
*/
|
|
336
|
+
type Plugin = {
|
|
337
|
+
/** A name for logs and errors. */
|
|
338
|
+
name: string;
|
|
339
|
+
/** The Hono middleware for this step. */
|
|
340
|
+
middleware?: MiddlewareHandler<AppServerEnv>;
|
|
341
|
+
/**
|
|
342
|
+
* Runs once before the server takes requests. A thrown error stops startup.
|
|
343
|
+
* On a serverless host, a thrown error fails the request, and the next
|
|
344
|
+
* request runs each `setup` again.
|
|
345
|
+
*/
|
|
346
|
+
setup?: (info: SetupInfo) => void | Promise<void>;
|
|
347
|
+
/** Runs at shutdown while the listeners drain. The server stops waiting for it at the drain deadline. */
|
|
348
|
+
onShutdown?: () => Promise<void>;
|
|
349
|
+
/**
|
|
350
|
+
* A value that this plugin's changes to a response depend on, such as the
|
|
351
|
+
* env values it writes into each document. The server adds it to the ETag
|
|
352
|
+
* of each static file that the request reaches after this plugin, so a 304
|
|
353
|
+
* never keeps a response made with an old value. Return `undefined` when
|
|
354
|
+
* the plugin changes nothing.
|
|
355
|
+
*/
|
|
356
|
+
etagPart?: () => string | undefined;
|
|
357
|
+
};
|
|
358
|
+
/** A running listener. */
|
|
359
|
+
type StartedListener = {
|
|
360
|
+
/** The URL the listener answers on. */
|
|
361
|
+
url: string;
|
|
362
|
+
/**
|
|
363
|
+
* Stops new connections and waits for open requests. At the deadline, it
|
|
364
|
+
* closes the connections that are still open.
|
|
365
|
+
*/
|
|
366
|
+
stop: (options: {
|
|
367
|
+
deadlineMs: number;
|
|
368
|
+
}) => Promise<void>;
|
|
369
|
+
};
|
|
370
|
+
/**
|
|
371
|
+
* How the server receives connections, separate from the request pipeline.
|
|
372
|
+
*
|
|
373
|
+
* @example
|
|
374
|
+
* createServer({ listeners: [tcp({ port: 8080 })] });
|
|
375
|
+
*/
|
|
376
|
+
type Listener = {
|
|
377
|
+
/** A name for logs. */
|
|
378
|
+
name: string;
|
|
379
|
+
start: (fetch: FetchHandler, options?: ListenerStartOptions) => Promise<StartedListener>;
|
|
380
|
+
};
|
|
381
|
+
/** What the server tells a listener when it starts it. */
|
|
382
|
+
type ListenerStartOptions = {
|
|
383
|
+
/**
|
|
384
|
+
* The `trustForwardedProto` of the server. A listener that builds each
|
|
385
|
+
* request itself can then take the scheme from `X-Forwarded-Proto` at once,
|
|
386
|
+
* so the server copies no request to change it.
|
|
387
|
+
* @default false
|
|
388
|
+
*/
|
|
389
|
+
trustForwardedProto?: boolean;
|
|
390
|
+
};
|
|
391
|
+
export { SetupInfo as C, ResponseEdge as E, ServerBindings as S, StaticFiles as T, RequestContext as _, FrameworkRuntime as a, ResponseHeaders as b, HostRuntime as c, ListenerBindings as d, ListenerStartOptions as f, Plugin as g, Mode as h, FileInfo as i, Lifecycle as l, LogSink as m, ByteRange as n, FrameworkRuntimeFactory as o, LogLevel as p, FetchHandler as r, HeaderHook as s, AppServerEnv as t, Listener as u, RequestLogger as v, StartedListener as w, SentResponse as x, RequestStore as y };
|
|
392
|
+
//# sourceMappingURL=types-DLYxYS6M.d.ts.map
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { r as HostBuild } from "./index-Bo5G9LuQ.js";
|
|
2
|
+
/** Options for {@link vercel}. */
|
|
3
|
+
export type VercelOptions = {
|
|
4
|
+
/**
|
|
5
|
+
* More URL path prefixes of the client build that Vercel's CDN serves,
|
|
6
|
+
* such as `["/blog-assets/"]`. Each starts and ends with `/`. `/assets/`
|
|
7
|
+
* is always one. Their files skip the pipeline, and the function does not
|
|
8
|
+
* carry them.
|
|
9
|
+
*/
|
|
10
|
+
cdnPaths?: readonly string[];
|
|
11
|
+
/** Headers for each file that the CDN serves, such as CORS headers. */
|
|
12
|
+
cdnHeaders?: Readonly<Record<string, string>>;
|
|
13
|
+
/** The Vercel regions of the function, such as `["iad1"]`. @default the project's */
|
|
14
|
+
regions?: readonly string[];
|
|
15
|
+
/** The memory of the function, in MB. @default the project's */
|
|
16
|
+
memory?: number;
|
|
17
|
+
/** The longest time that a request runs, in seconds. @default the project's */
|
|
18
|
+
maxDuration?: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* The build side of the vercel host. After the build, it writes
|
|
22
|
+
* `.vercel/output` in the Vite root, for `vercel deploy --prebuilt`:
|
|
23
|
+
*
|
|
24
|
+
* - `static/`: the files under `/assets/` and the other `cdnPaths`. The CDN
|
|
25
|
+
* serves them, and each file under `/assets/` gets a one-year immutable
|
|
26
|
+
* cache.
|
|
27
|
+
* - `functions/index.func/`: one Node.js function that runs the pipeline for
|
|
28
|
+
* each other request, with the whole server build and the rest of the
|
|
29
|
+
* client build.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* appServer({ host: vercel() });
|
|
33
|
+
*/
|
|
34
|
+
export declare function vercel(options?: VercelOptions): HostBuild;
|
|
35
|
+
//# sourceMappingURL=vercel-vite.d.ts.map
|