better-call 1.0.15 → 1.0.17
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/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +18 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +16 -16
- package/dist/index.js.map +1 -1
- package/dist/node.cjs +13 -10
- package/dist/node.cjs.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/node.js +13 -10
- package/dist/node.js.map +1 -1
- package/dist/{router-BcwNrqXF.d.cts → router-CLKBSbjV.d.cts} +24 -55
- package/dist/{router-BcwNrqXF.d.ts → router-CLKBSbjV.d.ts} +24 -55
- package/package.json +1 -1
package/dist/node.cjs
CHANGED
|
@@ -108,16 +108,19 @@ function getRequest({
|
|
|
108
108
|
const fullPath = baseUrl ? baseUrl + request.url : request.url;
|
|
109
109
|
const maybeConsumedReq = request;
|
|
110
110
|
let body = void 0;
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
body
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
controller
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
111
|
+
const method = request.method;
|
|
112
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
113
|
+
if (maybeConsumedReq.body !== void 0) {
|
|
114
|
+
const bodyContent = typeof maybeConsumedReq.body === "string" ? maybeConsumedReq.body : JSON.stringify(maybeConsumedReq.body);
|
|
115
|
+
body = new ReadableStream({
|
|
116
|
+
start(controller) {
|
|
117
|
+
controller.enqueue(new TextEncoder().encode(bodyContent));
|
|
118
|
+
controller.close();
|
|
119
|
+
}
|
|
120
|
+
});
|
|
121
|
+
} else {
|
|
122
|
+
body = get_raw_body(request, bodySizeLimit);
|
|
123
|
+
}
|
|
121
124
|
}
|
|
122
125
|
return new Request(base + fullPath, {
|
|
123
126
|
// @ts-expect-error
|
package/dist/node.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/node/index.ts","../src/adapters/node/request.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { getRequest, setResponse } from \"./request\";\nimport type { Router } from \"../../router.js\";\n\nexport function toNodeHandler(handler: Router[\"handler\"]) {\n\treturn async (req: IncomingMessage, res: ServerResponse) => {\n\t\tconst protocol =\n\t\t\treq.headers[\"x-forwarded-proto\"] || ((req.socket as any).encrypted ? \"https\" : \"http\");\n\t\tconst base = `${protocol}://${req.headers[\":authority\"] || req.headers.host}`;\n\t\tconst response = await handler(getRequest({ base, request: req }));\n\t\treturn setResponse(res, response);\n\t};\n}\n\nexport { getRequest, setResponse };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport * as set_cookie_parser from \"set-cookie-parser\";\n\nfunction get_raw_body(req: IncomingMessage, body_size_limit?: number) {\n\tconst h = req.headers;\n\n\tif (!h[\"content-type\"]) return null;\n\n\tconst content_length = Number(h[\"content-length\"]);\n\n\t// check if no request body\n\tif (\n\t\t(req.httpVersionMajor === 1 && isNaN(content_length) && h[\"transfer-encoding\"] == null) ||\n\t\tcontent_length === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tlet length = content_length;\n\n\tif (body_size_limit) {\n\t\tif (!length) {\n\t\t\tlength = body_size_limit;\n\t\t} else if (length > body_size_limit) {\n\t\t\tthrow Error(\n\t\t\t\t`Received content-length of ${length}, but only accept up to ${body_size_limit} bytes.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (req.destroyed) {\n\t\tconst readable = new ReadableStream();\n\t\treadable.cancel();\n\t\treturn readable;\n\t}\n\n\tlet size = 0;\n\tlet cancelled = false;\n\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\treq.on(\"error\", (error) => {\n\t\t\t\tcancelled = true;\n\t\t\t\tcontroller.error(error);\n\t\t\t});\n\n\t\t\treq.on(\"end\", () => {\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.close();\n\t\t\t});\n\n\t\t\treq.on(\"data\", (chunk) => {\n\t\t\t\tif (cancelled) return;\n\n\t\t\t\tsize += chunk.length;\n\n\t\t\t\tif (size > length) {\n\t\t\t\t\tcancelled = true;\n\n\t\t\t\t\tcontroller.error(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`request body size exceeded ${\n\t\t\t\t\t\t\t\tcontent_length ? \"'content-length'\" : \"BODY_SIZE_LIMIT\"\n\t\t\t\t\t\t\t} of ${length}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\tif (controller.desiredSize === null || controller.desiredSize <= 0) {\n\t\t\t\t\treq.pause();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tpull() {\n\t\t\treq.resume();\n\t\t},\n\n\t\tcancel(reason) {\n\t\t\tcancelled = true;\n\t\t\treq.destroy(reason);\n\t\t},\n\t});\n}\n\nexport function getRequest({\n\trequest,\n\tbase,\n\tbodySizeLimit,\n}: {\n\tbase: string;\n\tbodySizeLimit?: number;\n\trequest: IncomingMessage;\n}) {\n\t// In Express subrouters, `request.url` is relative to the mount path (e.g., '/auth/xxx'),\n\t// and `request.baseUrl` holds the mount path (e.g., '/api').\n\t// Build the full path as baseUrl + url when available to preserve the full route.\n\tconst baseUrl = (request as any)?.baseUrl as string | undefined;\n\tconst fullPath = baseUrl ? baseUrl + request.url : request.url;\n\n\t// Check if body has already been parsed by Express middleware\n\tconst maybeConsumedReq = request as any;\n\tlet body = undefined;\n\n\t// If body was already parsed by Express body-parser middleware\n\tif (maybeConsumedReq.body !== undefined) {\n\t\t// Convert parsed body back to a ReadableStream\n\t\tconst bodyContent =\n\t\t\ttypeof maybeConsumedReq.body === \"string\"\n\t\t\t\t? maybeConsumedReq.body\n\t\t\t\t: JSON.stringify(maybeConsumedReq.body);\n\n\t\tbody = new ReadableStream({\n\t\t\tstart(controller) {\n\t\t\t\tcontroller.enqueue(new TextEncoder().encode(bodyContent));\n\t\t\t\tcontroller.close();\n\t\t\t},\n\t\t});\n\t} else {\n\t\t// Otherwise, get the raw body stream\n\t\tbody = get_raw_body(request, bodySizeLimit);\n\t}\n\n\treturn new Request(base + fullPath, {\n\t\t// @ts-expect-error\n\t\tduplex: \"half\",\n\t\tmethod: request.method,\n\t\tbody,\n\t\theaders: request.headers as Record<string, string>,\n\t});\n}\n\nexport async function setResponse(res: ServerResponse, response: Response) {\n\tfor (const [key, value] of response.headers as any) {\n\t\ttry {\n\t\t\tres.setHeader(\n\t\t\t\tkey,\n\t\t\t\tkey === \"set-cookie\"\n\t\t\t\t\t? set_cookie_parser.splitCookiesString(response.headers.get(key) as string)\n\t\t\t\t\t: value,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tres.getHeaderNames().forEach((name) => res.removeHeader(name));\n\t\t\tres.writeHead(500).end(String(error));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tres.writeHead(response.status);\n\n\tif (!response.body) {\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tif (response.body.locked) {\n\t\tres.end(\n\t\t\t\"Fatal error: Response body is locked. \" +\n\t\t\t\t\"This can happen when the response was already read (for example through 'response.json()' or 'response.text()').\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconst reader = response.body.getReader();\n\n\tif (res.destroyed) {\n\t\treader.cancel();\n\t\treturn;\n\t}\n\n\tconst cancel = (error?: Error) => {\n\t\tres.off(\"close\", cancel);\n\t\tres.off(\"error\", cancel);\n\n\t\t// If the reader has already been interrupted with an error earlier,\n\t\t// then it will appear here, it is useless, but it needs to be catch.\n\t\treader.cancel(error).catch(() => {});\n\t\tif (error) res.destroy(error);\n\t};\n\n\tres.on(\"close\", cancel);\n\tres.on(\"error\", cancel);\n\n\tnext();\n\tasync function next() {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (!res.write(value)) {\n\t\t\t\t\tres.once(\"drain\", next);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tres.end();\n\t\t} catch (error) {\n\t\t\tcancel(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,wBAAmC;AAEnC,SAAS,aAAa,KAAsB,iBAA0B;AACrE,QAAM,IAAI,IAAI;AAEd,MAAI,CAAC,EAAE,cAAc,EAAG,QAAO;AAE/B,QAAM,iBAAiB,OAAO,EAAE,gBAAgB,CAAC;AAGjD,MACE,IAAI,qBAAqB,KAAK,MAAM,cAAc,KAAK,EAAE,mBAAmB,KAAK,QAClF,mBAAmB,GAClB;AACD,WAAO;AAAA,EACR;AAEA,MAAI,SAAS;AAEb,MAAI,iBAAiB;AACpB,QAAI,CAAC,QAAQ;AACZ,eAAS;AAAA,IACV,WAAW,SAAS,iBAAiB;AACpC,YAAM;AAAA,QACL,8BAA8B,MAAM,2BAA2B,eAAe;AAAA,MAC/E;AAAA,IACD;AAAA,EACD;AAEA,MAAI,IAAI,WAAW;AAClB,UAAM,WAAW,IAAI,eAAe;AACpC,aAAS,OAAO;AAChB,WAAO;AAAA,EACR;AAEA,MAAI,OAAO;AACX,MAAI,YAAY;AAEhB,SAAO,IAAI,eAAe;AAAA,IACzB,MAAM,YAAY;AACjB,UAAI,GAAG,SAAS,CAAC,UAAU;AAC1B,oBAAY;AACZ,mBAAW,MAAM,KAAK;AAAA,MACvB,CAAC;AAED,UAAI,GAAG,OAAO,MAAM;AACnB,YAAI,UAAW;AACf,mBAAW,MAAM;AAAA,MAClB,CAAC;AAED,UAAI,GAAG,QAAQ,CAAC,UAAU;AACzB,YAAI,UAAW;AAEf,gBAAQ,MAAM;AAEd,YAAI,OAAO,QAAQ;AAClB,sBAAY;AAEZ,qBAAW;AAAA,YACV,IAAI;AAAA,cACH,8BACC,iBAAiB,qBAAqB,iBACvC,OAAO,MAAM;AAAA,YACd;AAAA,UACD;AACA;AAAA,QACD;AAEA,mBAAW,QAAQ,KAAK;AAExB,YAAI,WAAW,gBAAgB,QAAQ,WAAW,eAAe,GAAG;AACnE,cAAI,MAAM;AAAA,QACX;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IAEA,OAAO;AACN,UAAI,OAAO;AAAA,IACZ;AAAA,IAEA,OAAO,QAAQ;AACd,kBAAY;AACZ,UAAI,QAAQ,MAAM;AAAA,IACnB;AAAA,EACD,CAAC;AACF;AAEO,SAAS,WAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACD,GAIG;AAIF,QAAM,UAAW,SAAiB;AAClC,QAAM,WAAW,UAAU,UAAU,QAAQ,MAAM,QAAQ;AAG3D,QAAM,mBAAmB;AACzB,MAAI,OAAO;
|
|
1
|
+
{"version":3,"sources":["../src/adapters/node/index.ts","../src/adapters/node/request.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { getRequest, setResponse } from \"./request\";\nimport type { Router } from \"../../router.js\";\n\nexport function toNodeHandler(handler: Router[\"handler\"]) {\n\treturn async (req: IncomingMessage, res: ServerResponse) => {\n\t\tconst protocol =\n\t\t\treq.headers[\"x-forwarded-proto\"] || ((req.socket as any).encrypted ? \"https\" : \"http\");\n\t\tconst base = `${protocol}://${req.headers[\":authority\"] || req.headers.host}`;\n\t\tconst response = await handler(getRequest({ base, request: req }));\n\t\treturn setResponse(res, response);\n\t};\n}\n\nexport { getRequest, setResponse };\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport * as set_cookie_parser from \"set-cookie-parser\";\n\nfunction get_raw_body(req: IncomingMessage, body_size_limit?: number) {\n\tconst h = req.headers;\n\n\tif (!h[\"content-type\"]) return null;\n\n\tconst content_length = Number(h[\"content-length\"]);\n\n\t// check if no request body\n\tif (\n\t\t(req.httpVersionMajor === 1 && isNaN(content_length) && h[\"transfer-encoding\"] == null) ||\n\t\tcontent_length === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tlet length = content_length;\n\n\tif (body_size_limit) {\n\t\tif (!length) {\n\t\t\tlength = body_size_limit;\n\t\t} else if (length > body_size_limit) {\n\t\t\tthrow Error(\n\t\t\t\t`Received content-length of ${length}, but only accept up to ${body_size_limit} bytes.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (req.destroyed) {\n\t\tconst readable = new ReadableStream();\n\t\treadable.cancel();\n\t\treturn readable;\n\t}\n\n\tlet size = 0;\n\tlet cancelled = false;\n\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\treq.on(\"error\", (error) => {\n\t\t\t\tcancelled = true;\n\t\t\t\tcontroller.error(error);\n\t\t\t});\n\n\t\t\treq.on(\"end\", () => {\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.close();\n\t\t\t});\n\n\t\t\treq.on(\"data\", (chunk) => {\n\t\t\t\tif (cancelled) return;\n\n\t\t\t\tsize += chunk.length;\n\n\t\t\t\tif (size > length) {\n\t\t\t\t\tcancelled = true;\n\n\t\t\t\t\tcontroller.error(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`request body size exceeded ${\n\t\t\t\t\t\t\t\tcontent_length ? \"'content-length'\" : \"BODY_SIZE_LIMIT\"\n\t\t\t\t\t\t\t} of ${length}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\tif (controller.desiredSize === null || controller.desiredSize <= 0) {\n\t\t\t\t\treq.pause();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tpull() {\n\t\t\treq.resume();\n\t\t},\n\n\t\tcancel(reason) {\n\t\t\tcancelled = true;\n\t\t\treq.destroy(reason);\n\t\t},\n\t});\n}\n\nexport function getRequest({\n\trequest,\n\tbase,\n\tbodySizeLimit,\n}: {\n\tbase: string;\n\tbodySizeLimit?: number;\n\trequest: IncomingMessage;\n}) {\n\t// In Express subrouters, `request.url` is relative to the mount path (e.g., '/auth/xxx'),\n\t// and `request.baseUrl` holds the mount path (e.g., '/api').\n\t// Build the full path as baseUrl + url when available to preserve the full route.\n\tconst baseUrl = (request as any)?.baseUrl as string | undefined;\n\tconst fullPath = baseUrl ? baseUrl + request.url : request.url;\n\n\t// Check if body has already been parsed by Express middleware\n\tconst maybeConsumedReq = request as any;\n\tlet body = undefined;\n\n\tconst method = request.method;\n\t// Request with GET/HEAD method cannot have body.\n\tif (method !== \"GET\" && method !== \"HEAD\") {\n\t\t// If body was already parsed by Express body-parser middleware\n\t\tif (maybeConsumedReq.body !== undefined) {\n\t\t\t// Convert parsed body back to a ReadableStream\n\t\t\tconst bodyContent =\n\t\t\t\ttypeof maybeConsumedReq.body === \"string\"\n\t\t\t\t\t? maybeConsumedReq.body\n\t\t\t\t\t: JSON.stringify(maybeConsumedReq.body);\n\n\t\t\tbody = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tcontroller.enqueue(new TextEncoder().encode(bodyContent));\n\t\t\t\t\tcontroller.close();\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\t// Otherwise, get the raw body stream\n\t\t\tbody = get_raw_body(request, bodySizeLimit);\n\t\t}\n\t}\n\n\treturn new Request(base + fullPath, {\n\t\t// @ts-expect-error\n\t\tduplex: \"half\",\n\t\tmethod: request.method,\n\t\tbody,\n\t\theaders: request.headers as Record<string, string>,\n\t});\n}\n\nexport async function setResponse(res: ServerResponse, response: Response) {\n\tfor (const [key, value] of response.headers as any) {\n\t\ttry {\n\t\t\tres.setHeader(\n\t\t\t\tkey,\n\t\t\t\tkey === \"set-cookie\"\n\t\t\t\t\t? set_cookie_parser.splitCookiesString(response.headers.get(key) as string)\n\t\t\t\t\t: value,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tres.getHeaderNames().forEach((name) => res.removeHeader(name));\n\t\t\tres.writeHead(500).end(String(error));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tres.writeHead(response.status);\n\n\tif (!response.body) {\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tif (response.body.locked) {\n\t\tres.end(\n\t\t\t\"Fatal error: Response body is locked. \" +\n\t\t\t\t\"This can happen when the response was already read (for example through 'response.json()' or 'response.text()').\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconst reader = response.body.getReader();\n\n\tif (res.destroyed) {\n\t\treader.cancel();\n\t\treturn;\n\t}\n\n\tconst cancel = (error?: Error) => {\n\t\tres.off(\"close\", cancel);\n\t\tres.off(\"error\", cancel);\n\n\t\t// If the reader has already been interrupted with an error earlier,\n\t\t// then it will appear here, it is useless, but it needs to be catch.\n\t\treader.cancel(error).catch(() => {});\n\t\tif (error) res.destroy(error);\n\t};\n\n\tres.on(\"close\", cancel);\n\tres.on(\"error\", cancel);\n\n\tnext();\n\tasync function next() {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (!res.write(value)) {\n\t\t\t\t\tres.once(\"drain\", next);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tres.end();\n\t\t} catch (error) {\n\t\t\tcancel(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACCA,wBAAmC;AAEnC,SAAS,aAAa,KAAsB,iBAA0B;AACrE,QAAM,IAAI,IAAI;AAEd,MAAI,CAAC,EAAE,cAAc,EAAG,QAAO;AAE/B,QAAM,iBAAiB,OAAO,EAAE,gBAAgB,CAAC;AAGjD,MACE,IAAI,qBAAqB,KAAK,MAAM,cAAc,KAAK,EAAE,mBAAmB,KAAK,QAClF,mBAAmB,G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AAEA,QAAM,SAAS,CAAC,UAAkB;AACjC,QAAI,IAAI,SAAS,MAAM;AACvB,QAAI,IAAI,SAAS,MAAM;AAIvB,WAAO,OAAO,KAAK,EAAE,MAAM,MAAM;AAAA,IAAC,CAAC;AACnC,QAAI,MAAO,KAAI,QAAQ,KAAK;AAAA,EAC7B;AAEA,MAAI,GAAG,SAAS,MAAM;AACtB,MAAI,GAAG,SAAS,MAAM;AAEtB,OAAK;AACL,iBAAe,OAAO;AACrB,QAAI;AACH,iBAAS;AACR,cAAM,EAAE,MAAM,MAAM,IAAI,MAAM,OAAO,KAAK;AAE1C,YAAI,KAAM;AAEV,YAAI,CAAC,IAAI,MAAM,KAAK,GAAG;AACtB,cAAI,KAAK,SAAS,IAAI;AACtB;AAAA,QACD;AAAA,MACD;AACA,UAAI,IAAI;AAAA,IACT,SAAS,OAAO;AACf,aAAO,iBAAiB,QAAQ,QAAQ,IAAI,MAAM,OAAO,KAAK,CAAC,CAAC;AAAA,IACjE;AAAA,EACD;AACD;;;AD3MO,SAAS,cAAc,SAA4B;AACzD,SAAO,OAAO,KAAsB,QAAwB;AAC3D,UAAM,WACL,IAAI,QAAQ,mBAAmB,MAAO,IAAI,OAAe,YAAY,UAAU;AAChF,UAAM,OAAO,GAAG,QAAQ,MAAM,IAAI,QAAQ,YAAY,KAAK,IAAI,QAAQ,IAAI;AAC3E,UAAM,WAAW,MAAM,QAAQ,WAAW,EAAE,MAAM,SAAS,IAAI,CAAC,CAAC;AACjE,WAAO,YAAY,KAAK,QAAQ;AAAA,EACjC;AACD;","names":[]}
|
package/dist/node.d.cts
CHANGED
package/dist/node.d.ts
CHANGED
package/dist/node.js
CHANGED
|
@@ -70,16 +70,19 @@ function getRequest({
|
|
|
70
70
|
const fullPath = baseUrl ? baseUrl + request.url : request.url;
|
|
71
71
|
const maybeConsumedReq = request;
|
|
72
72
|
let body = void 0;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
body
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
controller
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
73
|
+
const method = request.method;
|
|
74
|
+
if (method !== "GET" && method !== "HEAD") {
|
|
75
|
+
if (maybeConsumedReq.body !== void 0) {
|
|
76
|
+
const bodyContent = typeof maybeConsumedReq.body === "string" ? maybeConsumedReq.body : JSON.stringify(maybeConsumedReq.body);
|
|
77
|
+
body = new ReadableStream({
|
|
78
|
+
start(controller) {
|
|
79
|
+
controller.enqueue(new TextEncoder().encode(bodyContent));
|
|
80
|
+
controller.close();
|
|
81
|
+
}
|
|
82
|
+
});
|
|
83
|
+
} else {
|
|
84
|
+
body = get_raw_body(request, bodySizeLimit);
|
|
85
|
+
}
|
|
83
86
|
}
|
|
84
87
|
return new Request(base + fullPath, {
|
|
85
88
|
// @ts-expect-error
|
package/dist/node.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/adapters/node/request.ts","../src/adapters/node/index.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport * as set_cookie_parser from \"set-cookie-parser\";\n\nfunction get_raw_body(req: IncomingMessage, body_size_limit?: number) {\n\tconst h = req.headers;\n\n\tif (!h[\"content-type\"]) return null;\n\n\tconst content_length = Number(h[\"content-length\"]);\n\n\t// check if no request body\n\tif (\n\t\t(req.httpVersionMajor === 1 && isNaN(content_length) && h[\"transfer-encoding\"] == null) ||\n\t\tcontent_length === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tlet length = content_length;\n\n\tif (body_size_limit) {\n\t\tif (!length) {\n\t\t\tlength = body_size_limit;\n\t\t} else if (length > body_size_limit) {\n\t\t\tthrow Error(\n\t\t\t\t`Received content-length of ${length}, but only accept up to ${body_size_limit} bytes.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (req.destroyed) {\n\t\tconst readable = new ReadableStream();\n\t\treadable.cancel();\n\t\treturn readable;\n\t}\n\n\tlet size = 0;\n\tlet cancelled = false;\n\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\treq.on(\"error\", (error) => {\n\t\t\t\tcancelled = true;\n\t\t\t\tcontroller.error(error);\n\t\t\t});\n\n\t\t\treq.on(\"end\", () => {\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.close();\n\t\t\t});\n\n\t\t\treq.on(\"data\", (chunk) => {\n\t\t\t\tif (cancelled) return;\n\n\t\t\t\tsize += chunk.length;\n\n\t\t\t\tif (size > length) {\n\t\t\t\t\tcancelled = true;\n\n\t\t\t\t\tcontroller.error(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`request body size exceeded ${\n\t\t\t\t\t\t\t\tcontent_length ? \"'content-length'\" : \"BODY_SIZE_LIMIT\"\n\t\t\t\t\t\t\t} of ${length}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\tif (controller.desiredSize === null || controller.desiredSize <= 0) {\n\t\t\t\t\treq.pause();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tpull() {\n\t\t\treq.resume();\n\t\t},\n\n\t\tcancel(reason) {\n\t\t\tcancelled = true;\n\t\t\treq.destroy(reason);\n\t\t},\n\t});\n}\n\nexport function getRequest({\n\trequest,\n\tbase,\n\tbodySizeLimit,\n}: {\n\tbase: string;\n\tbodySizeLimit?: number;\n\trequest: IncomingMessage;\n}) {\n\t// In Express subrouters, `request.url` is relative to the mount path (e.g., '/auth/xxx'),\n\t// and `request.baseUrl` holds the mount path (e.g., '/api').\n\t// Build the full path as baseUrl + url when available to preserve the full route.\n\tconst baseUrl = (request as any)?.baseUrl as string | undefined;\n\tconst fullPath = baseUrl ? baseUrl + request.url : request.url;\n\n\t// Check if body has already been parsed by Express middleware\n\tconst maybeConsumedReq = request as any;\n\tlet body = undefined;\n\n\t// If body was already parsed by Express body-parser middleware\n\tif (maybeConsumedReq.body !== undefined) {\n\t\t// Convert parsed body back to a ReadableStream\n\t\tconst bodyContent =\n\t\t\ttypeof maybeConsumedReq.body === \"string\"\n\t\t\t\t? maybeConsumedReq.body\n\t\t\t\t: JSON.stringify(maybeConsumedReq.body);\n\n\t\tbody = new ReadableStream({\n\t\t\tstart(controller) {\n\t\t\t\tcontroller.enqueue(new TextEncoder().encode(bodyContent));\n\t\t\t\tcontroller.close();\n\t\t\t},\n\t\t});\n\t} else {\n\t\t// Otherwise, get the raw body stream\n\t\tbody = get_raw_body(request, bodySizeLimit);\n\t}\n\n\treturn new Request(base + fullPath, {\n\t\t// @ts-expect-error\n\t\tduplex: \"half\",\n\t\tmethod: request.method,\n\t\tbody,\n\t\theaders: request.headers as Record<string, string>,\n\t});\n}\n\nexport async function setResponse(res: ServerResponse, response: Response) {\n\tfor (const [key, value] of response.headers as any) {\n\t\ttry {\n\t\t\tres.setHeader(\n\t\t\t\tkey,\n\t\t\t\tkey === \"set-cookie\"\n\t\t\t\t\t? set_cookie_parser.splitCookiesString(response.headers.get(key) as string)\n\t\t\t\t\t: value,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tres.getHeaderNames().forEach((name) => res.removeHeader(name));\n\t\t\tres.writeHead(500).end(String(error));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tres.writeHead(response.status);\n\n\tif (!response.body) {\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tif (response.body.locked) {\n\t\tres.end(\n\t\t\t\"Fatal error: Response body is locked. \" +\n\t\t\t\t\"This can happen when the response was already read (for example through 'response.json()' or 'response.text()').\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconst reader = response.body.getReader();\n\n\tif (res.destroyed) {\n\t\treader.cancel();\n\t\treturn;\n\t}\n\n\tconst cancel = (error?: Error) => {\n\t\tres.off(\"close\", cancel);\n\t\tres.off(\"error\", cancel);\n\n\t\t// If the reader has already been interrupted with an error earlier,\n\t\t// then it will appear here, it is useless, but it needs to be catch.\n\t\treader.cancel(error).catch(() => {});\n\t\tif (error) res.destroy(error);\n\t};\n\n\tres.on(\"close\", cancel);\n\tres.on(\"error\", cancel);\n\n\tnext();\n\tasync function next() {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (!res.write(value)) {\n\t\t\t\t\tres.once(\"drain\", next);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tres.end();\n\t\t} catch (error) {\n\t\t\tcancel(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n}\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { getRequest, setResponse } from \"./request\";\nimport type { Router } from \"../../router.js\";\n\nexport function toNodeHandler(handler: Router[\"handler\"]) {\n\treturn async (req: IncomingMessage, res: ServerResponse) => {\n\t\tconst protocol =\n\t\t\treq.headers[\"x-forwarded-proto\"] || ((req.socket as any).encrypted ? \"https\" : \"http\");\n\t\tconst base = `${protocol}://${req.headers[\":authority\"] || req.headers.host}`;\n\t\tconst response = await handler(getRequest({ base, request: req }));\n\t\treturn setResponse(res, response);\n\t};\n}\n\nexport { getRequest, setResponse };\n"],"mappings":";AACA,YAAY,uBAAuB;AAEnC,SAAS,aAAa,KAAsB,iBAA0B;AACrE,QAAM,IAAI,IAAI;AAEd,MAAI,CAAC,EAAE,cAAc,EAAG,QAAO;AAE/B,QAAM,iBAAiB,OAAO,EAAE,gBAAgB,CAAC;AAGjD,MACE,IAAI,qBAAqB,KAAK,MAAM,cAAc,KAAK,EAAE,mBAAmB,KAAK,QAClF,mBAAmB,GAClB;AACD,WAAO;AAAA,EACR;AAEA,MAAI,SAAS;AAEb,MAAI,iBAAiB;AACpB,QAAI,CAAC,QAAQ;AACZ,eAAS;AAAA,IACV,WAAW,SAAS,iBAAiB;AACpC,YAAM;AAAA,QACL,8BAA8B,MAAM,2BAA2B,eAAe;AAAA,MAC/E;AAAA,IACD;AAAA,EACD;AAEA,MAAI,IAAI,WAAW;AAClB,UAAM,WAAW,IAAI,eAAe;AACpC,aAAS,OAAO;AAChB,WAAO;AAAA,EACR;AAEA,MAAI,OAAO;AACX,MAAI,YAAY;AAEhB,SAAO,IAAI,eAAe;AAAA,IACzB,MAAM,YAAY;AACjB,UAAI,GAAG,SAAS,CAAC,UAAU;AAC1B,oBAAY;AACZ,mBAAW,MAAM,KAAK;AAAA,MACvB,CAAC;AAED,UAAI,GAAG,OAAO,MAAM;AACnB,YAAI,UAAW;AACf,mBAAW,MAAM;AAAA,MAClB,CAAC;AAED,UAAI,GAAG,QAAQ,CAAC,UAAU;AACzB,YAAI,UAAW;AAEf,gBAAQ,MAAM;AAEd,YAAI,OAAO,QAAQ;AAClB,sBAAY;AAEZ,qBAAW;AAAA,YACV,IAAI;AAAA,cACH,8BACC,iBAAiB,qBAAqB,iBACvC,OAAO,MAAM;AAAA,YACd;AAAA,UACD;AACA;AAAA,QACD;AAEA,mBAAW,QAAQ,KAAK;AAExB,YAAI,WAAW,gBAAgB,QAAQ,WAAW,eAAe,GAAG;AACnE,cAAI,MAAM;AAAA,QACX;AAAA,MACD,CAAC;AAAA,IACF;AAAA,IAEA,OAAO;AACN,UAAI,OAAO;AAAA,IACZ;AAAA,IAEA,OAAO,QAAQ;AACd,kBAAY;AACZ,UAAI,QAAQ,MAAM;AAAA,IACnB;AAAA,EACD,CAAC;AACF;AAEO,SAAS,WAAW;AAAA,EAC1B;AAAA,EACA;AAAA,EACA;AACD,GAIG;AAIF,QAAM,UAAW,SAAiB;AAClC,QAAM,WAAW,UAAU,UAAU,QAAQ,MAAM,QAAQ;AAG3D,QAAM,mBAAmB;AACzB,MAAI,OAAO;
|
|
1
|
+
{"version":3,"sources":["../src/adapters/node/request.ts","../src/adapters/node/index.ts"],"sourcesContent":["import type { IncomingMessage, ServerResponse } from \"node:http\";\nimport * as set_cookie_parser from \"set-cookie-parser\";\n\nfunction get_raw_body(req: IncomingMessage, body_size_limit?: number) {\n\tconst h = req.headers;\n\n\tif (!h[\"content-type\"]) return null;\n\n\tconst content_length = Number(h[\"content-length\"]);\n\n\t// check if no request body\n\tif (\n\t\t(req.httpVersionMajor === 1 && isNaN(content_length) && h[\"transfer-encoding\"] == null) ||\n\t\tcontent_length === 0\n\t) {\n\t\treturn null;\n\t}\n\n\tlet length = content_length;\n\n\tif (body_size_limit) {\n\t\tif (!length) {\n\t\t\tlength = body_size_limit;\n\t\t} else if (length > body_size_limit) {\n\t\t\tthrow Error(\n\t\t\t\t`Received content-length of ${length}, but only accept up to ${body_size_limit} bytes.`,\n\t\t\t);\n\t\t}\n\t}\n\n\tif (req.destroyed) {\n\t\tconst readable = new ReadableStream();\n\t\treadable.cancel();\n\t\treturn readable;\n\t}\n\n\tlet size = 0;\n\tlet cancelled = false;\n\n\treturn new ReadableStream({\n\t\tstart(controller) {\n\t\t\treq.on(\"error\", (error) => {\n\t\t\t\tcancelled = true;\n\t\t\t\tcontroller.error(error);\n\t\t\t});\n\n\t\t\treq.on(\"end\", () => {\n\t\t\t\tif (cancelled) return;\n\t\t\t\tcontroller.close();\n\t\t\t});\n\n\t\t\treq.on(\"data\", (chunk) => {\n\t\t\t\tif (cancelled) return;\n\n\t\t\t\tsize += chunk.length;\n\n\t\t\t\tif (size > length) {\n\t\t\t\t\tcancelled = true;\n\n\t\t\t\t\tcontroller.error(\n\t\t\t\t\t\tnew Error(\n\t\t\t\t\t\t\t`request body size exceeded ${\n\t\t\t\t\t\t\t\tcontent_length ? \"'content-length'\" : \"BODY_SIZE_LIMIT\"\n\t\t\t\t\t\t\t} of ${length}`,\n\t\t\t\t\t\t),\n\t\t\t\t\t);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tcontroller.enqueue(chunk);\n\n\t\t\t\tif (controller.desiredSize === null || controller.desiredSize <= 0) {\n\t\t\t\t\treq.pause();\n\t\t\t\t}\n\t\t\t});\n\t\t},\n\n\t\tpull() {\n\t\t\treq.resume();\n\t\t},\n\n\t\tcancel(reason) {\n\t\t\tcancelled = true;\n\t\t\treq.destroy(reason);\n\t\t},\n\t});\n}\n\nexport function getRequest({\n\trequest,\n\tbase,\n\tbodySizeLimit,\n}: {\n\tbase: string;\n\tbodySizeLimit?: number;\n\trequest: IncomingMessage;\n}) {\n\t// In Express subrouters, `request.url` is relative to the mount path (e.g., '/auth/xxx'),\n\t// and `request.baseUrl` holds the mount path (e.g., '/api').\n\t// Build the full path as baseUrl + url when available to preserve the full route.\n\tconst baseUrl = (request as any)?.baseUrl as string | undefined;\n\tconst fullPath = baseUrl ? baseUrl + request.url : request.url;\n\n\t// Check if body has already been parsed by Express middleware\n\tconst maybeConsumedReq = request as any;\n\tlet body = undefined;\n\n\tconst method = request.method;\n\t// Request with GET/HEAD method cannot have body.\n\tif (method !== \"GET\" && method !== \"HEAD\") {\n\t\t// If body was already parsed by Express body-parser middleware\n\t\tif (maybeConsumedReq.body !== undefined) {\n\t\t\t// Convert parsed body back to a ReadableStream\n\t\t\tconst bodyContent =\n\t\t\t\ttypeof maybeConsumedReq.body === \"string\"\n\t\t\t\t\t? maybeConsumedReq.body\n\t\t\t\t\t: JSON.stringify(maybeConsumedReq.body);\n\n\t\t\tbody = new ReadableStream({\n\t\t\t\tstart(controller) {\n\t\t\t\t\tcontroller.enqueue(new TextEncoder().encode(bodyContent));\n\t\t\t\t\tcontroller.close();\n\t\t\t\t},\n\t\t\t});\n\t\t} else {\n\t\t\t// Otherwise, get the raw body stream\n\t\t\tbody = get_raw_body(request, bodySizeLimit);\n\t\t}\n\t}\n\n\treturn new Request(base + fullPath, {\n\t\t// @ts-expect-error\n\t\tduplex: \"half\",\n\t\tmethod: request.method,\n\t\tbody,\n\t\theaders: request.headers as Record<string, string>,\n\t});\n}\n\nexport async function setResponse(res: ServerResponse, response: Response) {\n\tfor (const [key, value] of response.headers as any) {\n\t\ttry {\n\t\t\tres.setHeader(\n\t\t\t\tkey,\n\t\t\t\tkey === \"set-cookie\"\n\t\t\t\t\t? set_cookie_parser.splitCookiesString(response.headers.get(key) as string)\n\t\t\t\t\t: value,\n\t\t\t);\n\t\t} catch (error) {\n\t\t\tres.getHeaderNames().forEach((name) => res.removeHeader(name));\n\t\t\tres.writeHead(500).end(String(error));\n\t\t\treturn;\n\t\t}\n\t}\n\n\tres.writeHead(response.status);\n\n\tif (!response.body) {\n\t\tres.end();\n\t\treturn;\n\t}\n\n\tif (response.body.locked) {\n\t\tres.end(\n\t\t\t\"Fatal error: Response body is locked. \" +\n\t\t\t\t\"This can happen when the response was already read (for example through 'response.json()' or 'response.text()').\",\n\t\t);\n\t\treturn;\n\t}\n\n\tconst reader = response.body.getReader();\n\n\tif (res.destroyed) {\n\t\treader.cancel();\n\t\treturn;\n\t}\n\n\tconst cancel = (error?: Error) => {\n\t\tres.off(\"close\", cancel);\n\t\tres.off(\"error\", cancel);\n\n\t\t// If the reader has already been interrupted with an error earlier,\n\t\t// then it will appear here, it is useless, but it needs to be catch.\n\t\treader.cancel(error).catch(() => {});\n\t\tif (error) res.destroy(error);\n\t};\n\n\tres.on(\"close\", cancel);\n\tres.on(\"error\", cancel);\n\n\tnext();\n\tasync function next() {\n\t\ttry {\n\t\t\tfor (;;) {\n\t\t\t\tconst { done, value } = await reader.read();\n\n\t\t\t\tif (done) break;\n\n\t\t\t\tif (!res.write(value)) {\n\t\t\t\t\tres.once(\"drain\", next);\n\t\t\t\t\treturn;\n\t\t\t\t}\n\t\t\t}\n\t\t\tres.end();\n\t\t} catch (error) {\n\t\t\tcancel(error instanceof Error ? error : new Error(String(error)));\n\t\t}\n\t}\n}\n","import type { IncomingMessage, ServerResponse } from \"node:http\";\n\nimport { getRequest, setResponse } from \"./request\";\nimport type { Router } from \"../../router.js\";\n\nexport function toNodeHandler(handler: Router[\"handler\"]) {\n\treturn async (req: IncomingMessage, res: ServerResponse) => {\n\t\tconst protocol =\n\t\t\treq.headers[\"x-forwarded-proto\"] || ((req.socket as any).encrypted ? \"https\" : \"http\");\n\t\tconst base = `${protocol}://${req.headers[\":authority\"] || req.headers.host}`;\n\t\tconst response = await handler(getRequest({ base, request: req }));\n\t\treturn setResponse(res, response);\n\t};\n}\n\nexport { getRequest, setResponse };\n"],"mappings":";AACA,YAAY,uBAAuB;AAEnC,SAAS,aAAa,KAAsB,iBAA0B;AACrE,QAAM,IAAI,IAAI;AAEd,MAAI,CAAC,EAAE,cAAc,EAAG,QAAO;AAE/B,QAAM,iBAAiB,OAAO,EAAE,gBAAgB,CAAC;AAGjD,MACE,IAAI,qBAAqB,KAAK,MAAM,cAAc,KAAK,EAAE,mBAAmB,KAAK,QAClF,mBAAmB,GAClB;AACD,WAAO;AAAA,EACR;AAEA,MAAI,SAAS;AAEb,MAAI,iBAAiB;AACpB,QAAI,CAAC,QAAQ;AACZ,eAAS;AAAA,IACV,WAAW,SAAS,iBAAiB;AACpC,YAAM;AAAA,QACL,8BAA8B,MAAM,2BAA2B,eAAe;AAAA,MAC/E;AAAA,IACD;AAAA,EACD;AAEA,MAAI,IAAI,WAAW;AAClB,UAAM,WAAW,IAAI,eAAe;AACpC,aAAS,OAAO;AAChB,WAAO;AAAA,EACR;AAEA,MAAI,OAAO;AACX,MAAI,YAAY;AAEhB,SAAO,IAAI,eAAe;AAAA,IACzB,MAAM,YAAY;AACjB,UAAI,GAAG,SAAS,CAAC,UAAU;AAC1B,oBAAY;AACZ,mBAAW,MAAM,KAAK;AAAA,MACvB,CAAC;AAED,UAAI,GAAG,OAAO,MAAM;AACnB,YAAI,UAAW;AACf,mBAAW,MAAM;AAAA,MAClB,CAAC;AAED,UAAI,GAAG,QAAQ,CAAC,UAAU;AACzB,YAAI,UAAW;AAEf,gBAAQ,MAAM;AAEd,YAAI,OAAO,QAAQ;AAClB,sBAAY;AAEZ,qBAAW;AAAA,YACV,IAAI;AAAA,cACH,8BACC,iBAAiB,qBAAqB,iBACvC,OAAO,MAAM;AAAA,YACd;AAAA,UACD;AACA;AAAA,QACD;AAEA,mBAAW,QAAQ,KAAK;AAExB,YAAI,WAAW,gBAAgB,QAAQ,WAAW,eAAe,GAAG;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M,SAAS,IAAI,CAAC,CAAC;AACjE,WAAO,YAAY,KAAK,QAAQ;AAAA,EACjC;AACD;","names":[]}
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hide internal stack frames from the error stack trace.
|
|
3
|
+
*/
|
|
4
|
+
declare function hideInternalStackFrames(stack: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a custom error class that hides stack frames.
|
|
7
|
+
*/
|
|
8
|
+
declare function makeErrorForHideStackFrame<B extends new (...args: any[]) => Error>(Base: B, clazz: any): {
|
|
9
|
+
new (...args: ConstructorParameters<B>): InstanceType<B> & {
|
|
10
|
+
errorStack: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
4
13
|
declare const _statusCode: {
|
|
5
14
|
OK: number;
|
|
6
15
|
CREATED: number;
|
|
@@ -75,7 +84,7 @@ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "
|
|
|
75
84
|
code?: string;
|
|
76
85
|
cause?: unknown;
|
|
77
86
|
} & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
|
|
78
|
-
|
|
87
|
+
errorStack: string | undefined;
|
|
79
88
|
};
|
|
80
89
|
|
|
81
90
|
type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
@@ -97,7 +106,7 @@ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/$
|
|
|
97
106
|
[K in Param | keyof InferParamPath<Rest>]: string;
|
|
98
107
|
} : Path extends `${infer _Start}/*` ? {
|
|
99
108
|
[K in "_"]: string;
|
|
100
|
-
} : Path extends `${infer _Start}/${infer Rest}` ?
|
|
109
|
+
} : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {};
|
|
101
110
|
|
|
102
111
|
interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {
|
|
103
112
|
}
|
|
@@ -408,7 +417,7 @@ type InferInputMethod<Options extends EndpointOptions, Method = Options["method"
|
|
|
408
417
|
} : {
|
|
409
418
|
method: Method;
|
|
410
419
|
};
|
|
411
|
-
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ?
|
|
420
|
+
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {} : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
412
421
|
type InferParamInput<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
|
|
413
422
|
params?: Record<string, any>;
|
|
414
423
|
} : {
|
|
@@ -468,12 +477,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
468
477
|
stack?: string;
|
|
469
478
|
cause?: unknown;
|
|
470
479
|
} & {
|
|
471
|
-
|
|
472
|
-
name: string;
|
|
473
|
-
message: string;
|
|
474
|
-
stack?: string;
|
|
475
|
-
cause?: unknown;
|
|
476
|
-
};
|
|
480
|
+
errorStack: string | undefined;
|
|
477
481
|
};
|
|
478
482
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
479
483
|
message?: string;
|
|
@@ -492,12 +496,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
492
496
|
stack?: string;
|
|
493
497
|
cause?: unknown;
|
|
494
498
|
} & {
|
|
495
|
-
|
|
496
|
-
name: string;
|
|
497
|
-
message: string;
|
|
498
|
-
stack?: string;
|
|
499
|
-
cause?: unknown;
|
|
500
|
-
};
|
|
499
|
+
errorStack: string | undefined;
|
|
501
500
|
};
|
|
502
501
|
json: (json: Record<string, any>, routerResponse?: {
|
|
503
502
|
status?: number;
|
|
@@ -539,12 +538,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
539
538
|
stack?: string;
|
|
540
539
|
cause?: unknown;
|
|
541
540
|
} & {
|
|
542
|
-
|
|
543
|
-
name: string;
|
|
544
|
-
message: string;
|
|
545
|
-
stack?: string;
|
|
546
|
-
cause?: unknown;
|
|
547
|
-
};
|
|
541
|
+
errorStack: string | undefined;
|
|
548
542
|
};
|
|
549
543
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
550
544
|
message?: string;
|
|
@@ -563,12 +557,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
563
557
|
stack?: string;
|
|
564
558
|
cause?: unknown;
|
|
565
559
|
} & {
|
|
566
|
-
|
|
567
|
-
name: string;
|
|
568
|
-
message: string;
|
|
569
|
-
stack?: string;
|
|
570
|
-
cause?: unknown;
|
|
571
|
-
};
|
|
560
|
+
errorStack: string | undefined;
|
|
572
561
|
};
|
|
573
562
|
json: (json: Record<string, any>, routerResponse?: {
|
|
574
563
|
status?: number;
|
|
@@ -610,12 +599,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
610
599
|
stack?: string;
|
|
611
600
|
cause?: unknown;
|
|
612
601
|
} & {
|
|
613
|
-
|
|
614
|
-
name: string;
|
|
615
|
-
message: string;
|
|
616
|
-
stack?: string;
|
|
617
|
-
cause?: unknown;
|
|
618
|
-
};
|
|
602
|
+
errorStack: string | undefined;
|
|
619
603
|
};
|
|
620
604
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
621
605
|
message?: string;
|
|
@@ -634,12 +618,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
634
618
|
stack?: string;
|
|
635
619
|
cause?: unknown;
|
|
636
620
|
} & {
|
|
637
|
-
|
|
638
|
-
name: string;
|
|
639
|
-
message: string;
|
|
640
|
-
stack?: string;
|
|
641
|
-
cause?: unknown;
|
|
642
|
-
};
|
|
621
|
+
errorStack: string | undefined;
|
|
643
622
|
};
|
|
644
623
|
json: (json: Record<string, any>, routerResponse?: {
|
|
645
624
|
status?: number;
|
|
@@ -681,12 +660,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
681
660
|
stack?: string;
|
|
682
661
|
cause?: unknown;
|
|
683
662
|
} & {
|
|
684
|
-
|
|
685
|
-
name: string;
|
|
686
|
-
message: string;
|
|
687
|
-
stack?: string;
|
|
688
|
-
cause?: unknown;
|
|
689
|
-
};
|
|
663
|
+
errorStack: string | undefined;
|
|
690
664
|
};
|
|
691
665
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
692
666
|
message?: string;
|
|
@@ -705,12 +679,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
705
679
|
stack?: string;
|
|
706
680
|
cause?: unknown;
|
|
707
681
|
} & {
|
|
708
|
-
|
|
709
|
-
name: string;
|
|
710
|
-
message: string;
|
|
711
|
-
stack?: string;
|
|
712
|
-
cause?: unknown;
|
|
713
|
-
};
|
|
682
|
+
errorStack: string | undefined;
|
|
714
683
|
};
|
|
715
684
|
json: (json: Record<string, any>, routerResponse?: {
|
|
716
685
|
status?: number;
|
|
@@ -1313,4 +1282,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1313
1282
|
};
|
|
1314
1283
|
type Router = ReturnType<typeof createRouter>;
|
|
1315
1284
|
|
|
1316
|
-
export { type
|
|
1285
|
+
export { type MergeObject as $, APIError as A, type InferParam as B, type CookiePrefixOptions as C, type InferParamInput as D, type EndpointOptions as E, type InferRequest as F, type InferRequestInput as G, type HTTPMethod as H, type InferBodyInput as I, type InferHeaders as J, type InferHeadersInput as K, type InferUse as L, type MiddlewareOptions as M, type InferMiddlewareBody as N, type OpenAPISchemaType as O, type Path as P, type InferMiddlewareQuery as Q, type RouterConfig as R, type Status as S, type InputContext as T, createInternalContext as U, type RequiredKeysOf as V, type HasRequiredKeys as W, type Prettify as X, type IsEmptyObject as Y, type UnionToIntersection as Z, _statusCode as _, type EndpointContext as a, type InferParamPath as a0, type InferParamWildCard as a1, StandardSchemaV1 as a2, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, hideInternalStackFrames as r, serializeCookie as s, makeErrorForHideStackFrame as t, type Method as u, type InferBody as v, type InferQueryInput as w, type InferQuery as x, type InferMethod as y, type InferInputMethod as z };
|
|
@@ -1,6 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Hide internal stack frames from the error stack trace.
|
|
3
|
+
*/
|
|
4
|
+
declare function hideInternalStackFrames(stack: string): string;
|
|
5
|
+
/**
|
|
6
|
+
* Creates a custom error class that hides stack frames.
|
|
7
|
+
*/
|
|
8
|
+
declare function makeErrorForHideStackFrame<B extends new (...args: any[]) => Error>(Base: B, clazz: any): {
|
|
9
|
+
new (...args: ConstructorParameters<B>): InstanceType<B> & {
|
|
10
|
+
errorStack: string | undefined;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
4
13
|
declare const _statusCode: {
|
|
5
14
|
OK: number;
|
|
6
15
|
CREATED: number;
|
|
@@ -75,7 +84,7 @@ declare const APIError: new (status?: Status | "OK" | "CREATED" | "ACCEPTED" | "
|
|
|
75
84
|
code?: string;
|
|
76
85
|
cause?: unknown;
|
|
77
86
|
} & Record<string, any>) | undefined, headers?: HeadersInit | undefined, statusCode?: number | undefined) => InternalAPIError & {
|
|
78
|
-
|
|
87
|
+
errorStack: string | undefined;
|
|
79
88
|
};
|
|
80
89
|
|
|
81
90
|
type RequiredKeysOf<BaseType extends object> = Exclude<{
|
|
@@ -97,7 +106,7 @@ type InferParamWildCard<Path> = Path extends `${infer _Start}/*:${infer Param}/$
|
|
|
97
106
|
[K in Param | keyof InferParamPath<Rest>]: string;
|
|
98
107
|
} : Path extends `${infer _Start}/*` ? {
|
|
99
108
|
[K in "_"]: string;
|
|
100
|
-
} : Path extends `${infer _Start}/${infer Rest}` ?
|
|
109
|
+
} : Path extends `${infer _Start}/${infer Rest}` ? InferParamWildCard<Rest> : {};
|
|
101
110
|
|
|
102
111
|
interface MiddlewareOptions extends Omit<EndpointOptions, "method"> {
|
|
103
112
|
}
|
|
@@ -408,7 +417,7 @@ type InferInputMethod<Options extends EndpointOptions, Method = Options["method"
|
|
|
408
417
|
} : {
|
|
409
418
|
method: Method;
|
|
410
419
|
};
|
|
411
|
-
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ?
|
|
420
|
+
type InferParam<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {} : Prettify<InferParamPath<Path> & InferParamWildCard<Path>>;
|
|
412
421
|
type InferParamInput<Path extends string> = IsEmptyObject<InferParamPath<Path> & InferParamWildCard<Path>> extends true ? {
|
|
413
422
|
params?: Record<string, any>;
|
|
414
423
|
} : {
|
|
@@ -468,12 +477,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
468
477
|
stack?: string;
|
|
469
478
|
cause?: unknown;
|
|
470
479
|
} & {
|
|
471
|
-
|
|
472
|
-
name: string;
|
|
473
|
-
message: string;
|
|
474
|
-
stack?: string;
|
|
475
|
-
cause?: unknown;
|
|
476
|
-
};
|
|
480
|
+
errorStack: string | undefined;
|
|
477
481
|
};
|
|
478
482
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
479
483
|
message?: string;
|
|
@@ -492,12 +496,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
492
496
|
stack?: string;
|
|
493
497
|
cause?: unknown;
|
|
494
498
|
} & {
|
|
495
|
-
|
|
496
|
-
name: string;
|
|
497
|
-
message: string;
|
|
498
|
-
stack?: string;
|
|
499
|
-
cause?: unknown;
|
|
500
|
-
};
|
|
499
|
+
errorStack: string | undefined;
|
|
501
500
|
};
|
|
502
501
|
json: (json: Record<string, any>, routerResponse?: {
|
|
503
502
|
status?: number;
|
|
@@ -539,12 +538,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
539
538
|
stack?: string;
|
|
540
539
|
cause?: unknown;
|
|
541
540
|
} & {
|
|
542
|
-
|
|
543
|
-
name: string;
|
|
544
|
-
message: string;
|
|
545
|
-
stack?: string;
|
|
546
|
-
cause?: unknown;
|
|
547
|
-
};
|
|
541
|
+
errorStack: string | undefined;
|
|
548
542
|
};
|
|
549
543
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
550
544
|
message?: string;
|
|
@@ -563,12 +557,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
563
557
|
stack?: string;
|
|
564
558
|
cause?: unknown;
|
|
565
559
|
} & {
|
|
566
|
-
|
|
567
|
-
name: string;
|
|
568
|
-
message: string;
|
|
569
|
-
stack?: string;
|
|
570
|
-
cause?: unknown;
|
|
571
|
-
};
|
|
560
|
+
errorStack: string | undefined;
|
|
572
561
|
};
|
|
573
562
|
json: (json: Record<string, any>, routerResponse?: {
|
|
574
563
|
status?: number;
|
|
@@ -610,12 +599,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
610
599
|
stack?: string;
|
|
611
600
|
cause?: unknown;
|
|
612
601
|
} & {
|
|
613
|
-
|
|
614
|
-
name: string;
|
|
615
|
-
message: string;
|
|
616
|
-
stack?: string;
|
|
617
|
-
cause?: unknown;
|
|
618
|
-
};
|
|
602
|
+
errorStack: string | undefined;
|
|
619
603
|
};
|
|
620
604
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
621
605
|
message?: string;
|
|
@@ -634,12 +618,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
634
618
|
stack?: string;
|
|
635
619
|
cause?: unknown;
|
|
636
620
|
} & {
|
|
637
|
-
|
|
638
|
-
name: string;
|
|
639
|
-
message: string;
|
|
640
|
-
stack?: string;
|
|
641
|
-
cause?: unknown;
|
|
642
|
-
};
|
|
621
|
+
errorStack: string | undefined;
|
|
643
622
|
};
|
|
644
623
|
json: (json: Record<string, any>, routerResponse?: {
|
|
645
624
|
status?: number;
|
|
@@ -681,12 +660,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
681
660
|
stack?: string;
|
|
682
661
|
cause?: unknown;
|
|
683
662
|
} & {
|
|
684
|
-
|
|
685
|
-
name: string;
|
|
686
|
-
message: string;
|
|
687
|
-
stack?: string;
|
|
688
|
-
cause?: unknown;
|
|
689
|
-
};
|
|
663
|
+
errorStack: string | undefined;
|
|
690
664
|
};
|
|
691
665
|
error: (status: keyof typeof _statusCode | Status, body?: {
|
|
692
666
|
message?: string;
|
|
@@ -705,12 +679,7 @@ declare const createInternalContext: (context: InputContext<any, any>, { options
|
|
|
705
679
|
stack?: string;
|
|
706
680
|
cause?: unknown;
|
|
707
681
|
} & {
|
|
708
|
-
|
|
709
|
-
name: string;
|
|
710
|
-
message: string;
|
|
711
|
-
stack?: string;
|
|
712
|
-
cause?: unknown;
|
|
713
|
-
};
|
|
682
|
+
errorStack: string | undefined;
|
|
714
683
|
};
|
|
715
684
|
json: (json: Record<string, any>, routerResponse?: {
|
|
716
685
|
status?: number;
|
|
@@ -1313,4 +1282,4 @@ declare const createRouter: <E extends Record<string, Endpoint>, Config extends
|
|
|
1313
1282
|
};
|
|
1314
1283
|
type Router = ReturnType<typeof createRouter>;
|
|
1315
1284
|
|
|
1316
|
-
export { type
|
|
1285
|
+
export { type MergeObject as $, APIError as A, type InferParam as B, type CookiePrefixOptions as C, type InferParamInput as D, type EndpointOptions as E, type InferRequest as F, type InferRequestInput as G, type HTTPMethod as H, type InferBodyInput as I, type InferHeaders as J, type InferHeadersInput as K, type InferUse as L, type MiddlewareOptions as M, type InferMiddlewareBody as N, type OpenAPISchemaType as O, type Path as P, type InferMiddlewareQuery as Q, type RouterConfig as R, type Status as S, type InputContext as T, createInternalContext as U, type RequiredKeysOf as V, type HasRequiredKeys as W, type Prettify as X, type IsEmptyObject as Y, type UnionToIntersection as Z, _statusCode as _, type EndpointContext as a, type InferParamPath as a0, type InferParamWildCard as a1, StandardSchemaV1 as a2, type Endpoint as b, createEndpoint as c, type MiddlewareResponse as d, type MiddlewareContext as e, createMiddleware as f, type MiddlewareInputContext as g, type Middleware as h, createRouter as i, type Router as j, type CookieOptions as k, getCookieKey as l, serializeSignedCookie as m, type OpenAPIParameter as n, generator as o, parseCookies as p, getHTML as q, hideInternalStackFrames as r, serializeCookie as s, makeErrorForHideStackFrame as t, type Method as u, type InferBody as v, type InferQueryInput as w, type InferQuery as x, type InferMethod as y, type InferInputMethod as z };
|