@noy-db/in-rest 0.1.0-pre.3

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 ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 vLannaAi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,33 @@
1
+ # @noy-db/in-rest
2
+
3
+ [![npm](https://img.shields.io/npm/v/%40noy-db/in-rest.svg)](https://www.npmjs.com/package/@noy-db/in-rest)
4
+
5
+ > Framework-neutral REST API integration for noy-db
6
+
7
+ Part of [**`@noy-db/hub`**](https://www.npmjs.com/package/@noy-db/hub) — the zero-knowledge, offline-first, encrypted document store.
8
+
9
+ ## Install
10
+
11
+ ```bash
12
+ pnpm add @noy-db/hub @noy-db/in-rest
13
+ ```
14
+
15
+ ## What it is
16
+
17
+ Framework-neutral REST API integration for noy-db — createRestHandler with Hono, Express, Fastify, and Nitro subpath adapters.
18
+
19
+ ## Status
20
+
21
+ **Pre-release** (`0.1.0-pre.1`). API may change before `1.0`.
22
+
23
+ ## Documentation
24
+
25
+ See the [main repository](https://github.com/vLannaAi/noy-db#readme) for setup, examples, and the full subsystem catalog.
26
+
27
+ - Source — [`packages/in-rest`](https://github.com/vLannaAi/noy-db/tree/main/packages/in-rest)
28
+ - Issues — [github.com/vLannaAi/noy-db/issues](https://github.com/vLannaAi/noy-db/issues)
29
+ - Spec — [`SPEC.md`](https://github.com/vLannaAi/noy-db/blob/main/SPEC.md)
30
+
31
+ ## License
32
+
33
+ [MIT](./LICENSE) © vLannaAi
@@ -0,0 +1,82 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __export = (target, all) => {
9
+ for (var name in all)
10
+ __defProp(target, name, { get: all[name], enumerable: true });
11
+ };
12
+ var __copyProps = (to, from, except, desc) => {
13
+ if (from && typeof from === "object" || typeof from === "function") {
14
+ for (let key of __getOwnPropNames(from))
15
+ if (!__hasOwnProp.call(to, key) && key !== except)
16
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
+ }
18
+ return to;
19
+ };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
28
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
+
30
+ // src/adapters/express.ts
31
+ var express_exports = {};
32
+ __export(express_exports, {
33
+ expressAdapter: () => expressAdapter
34
+ });
35
+ module.exports = __toCommonJS(express_exports);
36
+ var import_express = __toESM(require("express"), 1);
37
+ function expressAdapter(handler) {
38
+ const router = import_express.default.Router();
39
+ router.use(async (req, res, next) => {
40
+ const headers = {};
41
+ for (const [k, v] of Object.entries(req.headers)) {
42
+ if (typeof v === "string") headers[k] = v;
43
+ }
44
+ const url = new URL(req.path, "http://localhost");
45
+ for (const [k, v] of Object.entries(req.query)) {
46
+ if (typeof v === "string") url.searchParams.append(k, v);
47
+ }
48
+ let bodyCache;
49
+ let bodyRead = false;
50
+ const restReq = {
51
+ method: req.method,
52
+ pathname: req.path,
53
+ searchParams: url.searchParams,
54
+ headers,
55
+ json: () => {
56
+ if (!bodyRead) {
57
+ bodyCache = req.body;
58
+ bodyRead = true;
59
+ }
60
+ return Promise.resolve(bodyCache);
61
+ }
62
+ };
63
+ try {
64
+ const restRes = await handler.handle(restReq);
65
+ res.status(restRes.status);
66
+ for (const [k, v] of Object.entries(restRes.headers)) res.setHeader(k, v);
67
+ if (restRes.body !== null) {
68
+ res.end(restRes.body);
69
+ } else {
70
+ res.end();
71
+ }
72
+ } catch (err) {
73
+ next(err);
74
+ }
75
+ });
76
+ return router;
77
+ }
78
+ // Annotate the CommonJS export names for ESM import in node:
79
+ 0 && (module.exports = {
80
+ expressAdapter
81
+ });
82
+ //# sourceMappingURL=express.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/express.ts"],"sourcesContent":["import express from 'express'\nimport type { Router as ExpressRouter } from 'express'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function expressAdapter(handler: NoydbRestHandler): ExpressRouter {\n const router = express.Router()\n\n // Express 5 dropped support for bare `*` as a wildcard path — use router.use()\n // which runs for all methods and paths without needing path-to-regexp.\n router.use(async (req, res, next) => {\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(req.headers)) {\n if (typeof v === 'string') headers[k] = v\n }\n\n const url = new URL(req.path, 'http://localhost')\n for (const [k, v] of Object.entries(req.query)) {\n if (typeof v === 'string') url.searchParams.append(k, v)\n }\n\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: req.method,\n pathname: req.path,\n searchParams: url.searchParams,\n headers,\n json: () => {\n if (!bodyRead) { bodyCache = req.body; bodyRead = true }\n return Promise.resolve(bodyCache)\n },\n }\n\n // Express 5 awaits returned promises from middleware, BUT throwing\n // inside `async` middleware only reaches the default error handler\n // when the adapter forwards the rejection via `next(err)`. Unlike\n // the fastify / hono / nitro adapters (whose frameworks hoist any\n // thrown error to their own 500 path automatically), Express needs\n // the explicit try/catch.\n try {\n const restRes = await handler.handle(restReq)\n res.status(restRes.status)\n for (const [k, v] of Object.entries(restRes.headers)) res.setHeader(k, v)\n if (restRes.body !== null) {\n res.end(restRes.body)\n } else {\n res.end()\n }\n } catch (err) {\n next(err)\n }\n })\n\n return router\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,qBAAoB;AAIb,SAAS,eAAe,SAA0C;AACvE,QAAM,SAAS,eAAAA,QAAQ,OAAO;AAI9B,SAAO,IAAI,OAAO,KAAK,KAAK,SAAS;AACnC,UAAM,UAAkC,CAAC;AACzC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,IAAI,OAAO,GAAG;AAChD,UAAI,OAAO,MAAM,SAAU,SAAQ,CAAC,IAAI;AAAA,IAC1C;AAEA,UAAM,MAAM,IAAI,IAAI,IAAI,MAAM,kBAAkB;AAChD,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,IAAI,KAAK,GAAG;AAC9C,UAAI,OAAO,MAAM,SAAU,KAAI,aAAa,OAAO,GAAG,CAAC;AAAA,IACzD;AAEA,QAAI;AACJ,QAAI,WAAW;AAEf,UAAM,UAAuB;AAAA,MAC3B,QAAQ,IAAI;AAAA,MACZ,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,MAAM;AACV,YAAI,CAAC,UAAU;AAAE,sBAAY,IAAI;AAAM,qBAAW;AAAA,QAAK;AACvD,eAAO,QAAQ,QAAQ,SAAS;AAAA,MAClC;AAAA,IACF;AAQA,QAAI;AACF,YAAM,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5C,UAAI,OAAO,QAAQ,MAAM;AACzB,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,EAAG,KAAI,UAAU,GAAG,CAAC;AACxE,UAAI,QAAQ,SAAS,MAAM;AACzB,YAAI,IAAI,QAAQ,IAAI;AAAA,MACtB,OAAO;AACL,YAAI,IAAI;AAAA,MACV;AAAA,IACF,SAAS,KAAK;AACZ,WAAK,GAAG;AAAA,IACV;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":["express"]}
@@ -0,0 +1,7 @@
1
+ import { Router } from 'express';
2
+ import { NoydbRestHandler } from '../index.cjs';
3
+ import '@noy-db/hub';
4
+
5
+ declare function expressAdapter(handler: NoydbRestHandler): Router;
6
+
7
+ export { expressAdapter };
@@ -0,0 +1,7 @@
1
+ import { Router } from 'express';
2
+ import { NoydbRestHandler } from '../index.js';
3
+ import '@noy-db/hub';
4
+
5
+ declare function expressAdapter(handler: NoydbRestHandler): Router;
6
+
7
+ export { expressAdapter };
@@ -0,0 +1,47 @@
1
+ // src/adapters/express.ts
2
+ import express from "express";
3
+ function expressAdapter(handler) {
4
+ const router = express.Router();
5
+ router.use(async (req, res, next) => {
6
+ const headers = {};
7
+ for (const [k, v] of Object.entries(req.headers)) {
8
+ if (typeof v === "string") headers[k] = v;
9
+ }
10
+ const url = new URL(req.path, "http://localhost");
11
+ for (const [k, v] of Object.entries(req.query)) {
12
+ if (typeof v === "string") url.searchParams.append(k, v);
13
+ }
14
+ let bodyCache;
15
+ let bodyRead = false;
16
+ const restReq = {
17
+ method: req.method,
18
+ pathname: req.path,
19
+ searchParams: url.searchParams,
20
+ headers,
21
+ json: () => {
22
+ if (!bodyRead) {
23
+ bodyCache = req.body;
24
+ bodyRead = true;
25
+ }
26
+ return Promise.resolve(bodyCache);
27
+ }
28
+ };
29
+ try {
30
+ const restRes = await handler.handle(restReq);
31
+ res.status(restRes.status);
32
+ for (const [k, v] of Object.entries(restRes.headers)) res.setHeader(k, v);
33
+ if (restRes.body !== null) {
34
+ res.end(restRes.body);
35
+ } else {
36
+ res.end();
37
+ }
38
+ } catch (err) {
39
+ next(err);
40
+ }
41
+ });
42
+ return router;
43
+ }
44
+ export {
45
+ expressAdapter
46
+ };
47
+ //# sourceMappingURL=express.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/express.ts"],"sourcesContent":["import express from 'express'\nimport type { Router as ExpressRouter } from 'express'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function expressAdapter(handler: NoydbRestHandler): ExpressRouter {\n const router = express.Router()\n\n // Express 5 dropped support for bare `*` as a wildcard path — use router.use()\n // which runs for all methods and paths without needing path-to-regexp.\n router.use(async (req, res, next) => {\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(req.headers)) {\n if (typeof v === 'string') headers[k] = v\n }\n\n const url = new URL(req.path, 'http://localhost')\n for (const [k, v] of Object.entries(req.query)) {\n if (typeof v === 'string') url.searchParams.append(k, v)\n }\n\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: req.method,\n pathname: req.path,\n searchParams: url.searchParams,\n headers,\n json: () => {\n if (!bodyRead) { bodyCache = req.body; bodyRead = true }\n return Promise.resolve(bodyCache)\n },\n }\n\n // Express 5 awaits returned promises from middleware, BUT throwing\n // inside `async` middleware only reaches the default error handler\n // when the adapter forwards the rejection via `next(err)`. Unlike\n // the fastify / hono / nitro adapters (whose frameworks hoist any\n // thrown error to their own 500 path automatically), Express needs\n // the explicit try/catch.\n try {\n const restRes = await handler.handle(restReq)\n res.status(restRes.status)\n for (const [k, v] of Object.entries(restRes.headers)) res.setHeader(k, v)\n if (restRes.body !== null) {\n res.end(restRes.body)\n } else {\n res.end()\n }\n } catch (err) {\n next(err)\n }\n })\n\n return router\n}\n"],"mappings":";AAAA,OAAO,aAAa;AAIb,SAAS,eAAe,SAA0C;AACvE,QAAM,SAAS,QAAQ,OAAO;AAI9B,SAAO,IAAI,OAAO,KAAK,KAAK,SAAS;AACnC,UAAM,UAAkC,CAAC;AACzC,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,IAAI,OAAO,GAAG;AAChD,UAAI,OAAO,MAAM,SAAU,SAAQ,CAAC,IAAI;AAAA,IAC1C;AAEA,UAAM,MAAM,IAAI,IAAI,IAAI,MAAM,kBAAkB;AAChD,eAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,IAAI,KAAK,GAAG;AAC9C,UAAI,OAAO,MAAM,SAAU,KAAI,aAAa,OAAO,GAAG,CAAC;AAAA,IACzD;AAEA,QAAI;AACJ,QAAI,WAAW;AAEf,UAAM,UAAuB;AAAA,MAC3B,QAAQ,IAAI;AAAA,MACZ,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,MAAM;AACV,YAAI,CAAC,UAAU;AAAE,sBAAY,IAAI;AAAM,qBAAW;AAAA,QAAK;AACvD,eAAO,QAAQ,QAAQ,SAAS;AAAA,MAClC;AAAA,IACF;AAQA,QAAI;AACF,YAAM,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5C,UAAI,OAAO,QAAQ,MAAM;AACzB,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,EAAG,KAAI,UAAU,GAAG,CAAC;AACxE,UAAI,QAAQ,SAAS,MAAM;AACzB,YAAI,IAAI,QAAQ,IAAI;AAAA,MACtB,OAAO;AACL,YAAI,IAAI;AAAA,MACV;AAAA,IACF,SAAS,KAAK;AACZ,WAAK,GAAG;AAAA,IACV;AAAA,EACF,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/fastify.ts
21
+ var fastify_exports = {};
22
+ __export(fastify_exports, {
23
+ fastifyPlugin: () => fastifyPlugin
24
+ });
25
+ module.exports = __toCommonJS(fastify_exports);
26
+ function fastifyPlugin(handler) {
27
+ return async function plugin(fastify) {
28
+ fastify.all("/*", async (request, reply) => {
29
+ const headers = {};
30
+ for (const [k, v] of Object.entries(request.headers)) {
31
+ if (typeof v === "string") headers[k] = v;
32
+ }
33
+ const url = new URL(request.url, "http://localhost");
34
+ let bodyCache;
35
+ let bodyRead = false;
36
+ const restReq = {
37
+ method: request.method,
38
+ pathname: url.pathname,
39
+ searchParams: url.searchParams,
40
+ headers,
41
+ json: () => {
42
+ if (!bodyRead) {
43
+ bodyCache = request.body;
44
+ bodyRead = true;
45
+ }
46
+ return Promise.resolve(bodyCache);
47
+ }
48
+ };
49
+ const restRes = await handler.handle(restReq);
50
+ reply.status(restRes.status);
51
+ for (const [k, v] of Object.entries(restRes.headers)) {
52
+ reply.header(k, v);
53
+ }
54
+ if (restRes.body !== null) {
55
+ return reply.send(restRes.body);
56
+ }
57
+ return reply.send();
58
+ });
59
+ };
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ fastifyPlugin
64
+ });
65
+ //# sourceMappingURL=fastify.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/fastify.ts"],"sourcesContent":["import type { FastifyPluginAsync } from 'fastify'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function fastifyPlugin(handler: NoydbRestHandler): FastifyPluginAsync {\n return async function plugin(fastify) {\n // Use '/*' — Fastify v5 / find-my-way requires the leading slash on wildcards\n // No explicit try/catch — Fastify v5 awaits the handler and routes\n // any rejection to its default error handler (which sends a 500).\n // Contrast with the Express adapter, which needs `next(err)`.\n fastify.all('/*', async (request, reply) => {\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(request.headers)) {\n if (typeof v === 'string') headers[k] = v\n }\n\n const url = new URL(request.url, 'http://localhost')\n\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: request.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n json: () => {\n if (!bodyRead) { bodyCache = request.body; bodyRead = true }\n return Promise.resolve(bodyCache)\n },\n }\n\n const restRes = await handler.handle(restReq)\n reply.status(restRes.status)\n for (const [k, v] of Object.entries(restRes.headers)) {\n reply.header(k, v)\n }\n if (restRes.body !== null) {\n return reply.send(restRes.body)\n }\n return reply.send()\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAGO,SAAS,cAAc,SAA+C;AAC3E,SAAO,eAAe,OAAO,SAAS;AAKpC,YAAQ,IAAI,MAAM,OAAO,SAAS,UAAU;AAC1C,YAAM,UAAkC,CAAC;AACzC,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACpD,YAAI,OAAO,MAAM,SAAU,SAAQ,CAAC,IAAI;AAAA,MAC1C;AAEA,YAAM,MAAM,IAAI,IAAI,QAAQ,KAAK,kBAAkB;AAEnD,UAAI;AACJ,UAAI,WAAW;AAEf,YAAM,UAAuB;AAAA,QAC3B,QAAQ,QAAQ;AAAA,QAChB,UAAU,IAAI;AAAA,QACd,cAAc,IAAI;AAAA,QAClB;AAAA,QACA,MAAM,MAAM;AACV,cAAI,CAAC,UAAU;AAAE,wBAAY,QAAQ;AAAM,uBAAW;AAAA,UAAK;AAC3D,iBAAO,QAAQ,QAAQ,SAAS;AAAA,QAClC;AAAA,MACF;AAEA,YAAM,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5C,YAAM,OAAO,QAAQ,MAAM;AAC3B,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACpD,cAAM,OAAO,GAAG,CAAC;AAAA,MACnB;AACA,UAAI,QAAQ,SAAS,MAAM;AACzB,eAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,MAChC;AACA,aAAO,MAAM,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { FastifyPluginAsync } from 'fastify';
2
+ import { NoydbRestHandler } from '../index.cjs';
3
+ import '@noy-db/hub';
4
+
5
+ declare function fastifyPlugin(handler: NoydbRestHandler): FastifyPluginAsync;
6
+
7
+ export { fastifyPlugin };
@@ -0,0 +1,7 @@
1
+ import { FastifyPluginAsync } from 'fastify';
2
+ import { NoydbRestHandler } from '../index.js';
3
+ import '@noy-db/hub';
4
+
5
+ declare function fastifyPlugin(handler: NoydbRestHandler): FastifyPluginAsync;
6
+
7
+ export { fastifyPlugin };
@@ -0,0 +1,40 @@
1
+ // src/adapters/fastify.ts
2
+ function fastifyPlugin(handler) {
3
+ return async function plugin(fastify) {
4
+ fastify.all("/*", async (request, reply) => {
5
+ const headers = {};
6
+ for (const [k, v] of Object.entries(request.headers)) {
7
+ if (typeof v === "string") headers[k] = v;
8
+ }
9
+ const url = new URL(request.url, "http://localhost");
10
+ let bodyCache;
11
+ let bodyRead = false;
12
+ const restReq = {
13
+ method: request.method,
14
+ pathname: url.pathname,
15
+ searchParams: url.searchParams,
16
+ headers,
17
+ json: () => {
18
+ if (!bodyRead) {
19
+ bodyCache = request.body;
20
+ bodyRead = true;
21
+ }
22
+ return Promise.resolve(bodyCache);
23
+ }
24
+ };
25
+ const restRes = await handler.handle(restReq);
26
+ reply.status(restRes.status);
27
+ for (const [k, v] of Object.entries(restRes.headers)) {
28
+ reply.header(k, v);
29
+ }
30
+ if (restRes.body !== null) {
31
+ return reply.send(restRes.body);
32
+ }
33
+ return reply.send();
34
+ });
35
+ };
36
+ }
37
+ export {
38
+ fastifyPlugin
39
+ };
40
+ //# sourceMappingURL=fastify.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/fastify.ts"],"sourcesContent":["import type { FastifyPluginAsync } from 'fastify'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function fastifyPlugin(handler: NoydbRestHandler): FastifyPluginAsync {\n return async function plugin(fastify) {\n // Use '/*' — Fastify v5 / find-my-way requires the leading slash on wildcards\n // No explicit try/catch — Fastify v5 awaits the handler and routes\n // any rejection to its default error handler (which sends a 500).\n // Contrast with the Express adapter, which needs `next(err)`.\n fastify.all('/*', async (request, reply) => {\n const headers: Record<string, string> = {}\n for (const [k, v] of Object.entries(request.headers)) {\n if (typeof v === 'string') headers[k] = v\n }\n\n const url = new URL(request.url, 'http://localhost')\n\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: request.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n json: () => {\n if (!bodyRead) { bodyCache = request.body; bodyRead = true }\n return Promise.resolve(bodyCache)\n },\n }\n\n const restRes = await handler.handle(restReq)\n reply.status(restRes.status)\n for (const [k, v] of Object.entries(restRes.headers)) {\n reply.header(k, v)\n }\n if (restRes.body !== null) {\n return reply.send(restRes.body)\n }\n return reply.send()\n })\n }\n}\n"],"mappings":";AAGO,SAAS,cAAc,SAA+C;AAC3E,SAAO,eAAe,OAAO,SAAS;AAKpC,YAAQ,IAAI,MAAM,OAAO,SAAS,UAAU;AAC1C,YAAM,UAAkC,CAAC;AACzC,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACpD,YAAI,OAAO,MAAM,SAAU,SAAQ,CAAC,IAAI;AAAA,MAC1C;AAEA,YAAM,MAAM,IAAI,IAAI,QAAQ,KAAK,kBAAkB;AAEnD,UAAI;AACJ,UAAI,WAAW;AAEf,YAAM,UAAuB;AAAA,QAC3B,QAAQ,QAAQ;AAAA,QAChB,UAAU,IAAI;AAAA,QACd,cAAc,IAAI;AAAA,QAClB;AAAA,QACA,MAAM,MAAM;AACV,cAAI,CAAC,UAAU;AAAE,wBAAY,QAAQ;AAAM,uBAAW;AAAA,UAAK;AAC3D,iBAAO,QAAQ,QAAQ,SAAS;AAAA,QAClC;AAAA,MACF;AAEA,YAAM,UAAU,MAAM,QAAQ,OAAO,OAAO;AAC5C,YAAM,OAAO,QAAQ,MAAM;AAC3B,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,QAAQ,OAAO,GAAG;AACpD,cAAM,OAAO,GAAG,CAAC;AAAA,MACnB;AACA,UAAI,QAAQ,SAAS,MAAM;AACzB,eAAO,MAAM,KAAK,QAAQ,IAAI;AAAA,MAChC;AACA,aAAO,MAAM,KAAK;AAAA,IACpB,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,54 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/hono.ts
21
+ var hono_exports = {};
22
+ __export(hono_exports, {
23
+ honoAdapter: () => honoAdapter
24
+ });
25
+ module.exports = __toCommonJS(hono_exports);
26
+ var import_hono = require("hono");
27
+ function honoAdapter(handler) {
28
+ const app = new import_hono.Hono();
29
+ app.all("*", async (c) => {
30
+ const headers = {};
31
+ c.req.raw.headers.forEach((v, k) => {
32
+ headers[k] = v;
33
+ });
34
+ const url = new URL(c.req.url);
35
+ const restReq = {
36
+ method: c.req.method,
37
+ pathname: url.pathname,
38
+ searchParams: url.searchParams,
39
+ headers,
40
+ json: () => c.req.json()
41
+ };
42
+ const res = await handler.handle(restReq);
43
+ return new Response(res.body, {
44
+ status: res.status,
45
+ headers: res.headers
46
+ });
47
+ });
48
+ return app;
49
+ }
50
+ // Annotate the CommonJS export names for ESM import in node:
51
+ 0 && (module.exports = {
52
+ honoAdapter
53
+ });
54
+ //# sourceMappingURL=hono.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/hono.ts"],"sourcesContent":["import { Hono } from 'hono'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function honoAdapter(handler: NoydbRestHandler): Hono {\n const app = new Hono()\n\n // No explicit try/catch — Hono's router surfaces any thrown error to\n // its `onError` handler (or the default 500 response) automatically.\n // Contrast with the Express adapter, which needs `next(err)`.\n app.all('*', async (c) => {\n const headers: Record<string, string> = {}\n c.req.raw.headers.forEach((v, k) => { headers[k] = v })\n\n const url = new URL(c.req.url)\n const restReq: RestRequest = {\n method: c.req.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n json: () => c.req.json<unknown>(),\n }\n\n const res = await handler.handle(restReq)\n // `RestResponse.body` is `string | Uint8Array | null`, all valid BodyInit.\n return new Response(res.body as BodyInit | null, {\n status: res.status,\n headers: res.headers,\n })\n })\n\n return app\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,kBAAqB;AAGd,SAAS,YAAY,SAAiC;AAC3D,QAAM,MAAM,IAAI,iBAAK;AAKrB,MAAI,IAAI,KAAK,OAAO,MAAM;AACxB,UAAM,UAAkC,CAAC;AACzC,MAAE,IAAI,IAAI,QAAQ,QAAQ,CAAC,GAAG,MAAM;AAAE,cAAQ,CAAC,IAAI;AAAA,IAAE,CAAC;AAEtD,UAAM,MAAM,IAAI,IAAI,EAAE,IAAI,GAAG;AAC7B,UAAM,UAAuB;AAAA,MAC3B,QAAQ,EAAE,IAAI;AAAA,MACd,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,MAAM,EAAE,IAAI,KAAc;AAAA,IAClC;AAEA,UAAM,MAAM,MAAM,QAAQ,OAAO,OAAO;AAExC,WAAO,IAAI,SAAS,IAAI,MAAyB;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ,SAAS,IAAI;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,7 @@
1
+ import { Hono } from 'hono';
2
+ import { NoydbRestHandler } from '../index.cjs';
3
+ import '@noy-db/hub';
4
+
5
+ declare function honoAdapter(handler: NoydbRestHandler): Hono;
6
+
7
+ export { honoAdapter };
@@ -0,0 +1,7 @@
1
+ import { Hono } from 'hono';
2
+ import { NoydbRestHandler } from '../index.js';
3
+ import '@noy-db/hub';
4
+
5
+ declare function honoAdapter(handler: NoydbRestHandler): Hono;
6
+
7
+ export { honoAdapter };
@@ -0,0 +1,29 @@
1
+ // src/adapters/hono.ts
2
+ import { Hono } from "hono";
3
+ function honoAdapter(handler) {
4
+ const app = new Hono();
5
+ app.all("*", async (c) => {
6
+ const headers = {};
7
+ c.req.raw.headers.forEach((v, k) => {
8
+ headers[k] = v;
9
+ });
10
+ const url = new URL(c.req.url);
11
+ const restReq = {
12
+ method: c.req.method,
13
+ pathname: url.pathname,
14
+ searchParams: url.searchParams,
15
+ headers,
16
+ json: () => c.req.json()
17
+ };
18
+ const res = await handler.handle(restReq);
19
+ return new Response(res.body, {
20
+ status: res.status,
21
+ headers: res.headers
22
+ });
23
+ });
24
+ return app;
25
+ }
26
+ export {
27
+ honoAdapter
28
+ };
29
+ //# sourceMappingURL=hono.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/hono.ts"],"sourcesContent":["import { Hono } from 'hono'\nimport type { NoydbRestHandler, RestRequest } from '../index.js'\n\nexport function honoAdapter(handler: NoydbRestHandler): Hono {\n const app = new Hono()\n\n // No explicit try/catch — Hono's router surfaces any thrown error to\n // its `onError` handler (or the default 500 response) automatically.\n // Contrast with the Express adapter, which needs `next(err)`.\n app.all('*', async (c) => {\n const headers: Record<string, string> = {}\n c.req.raw.headers.forEach((v, k) => { headers[k] = v })\n\n const url = new URL(c.req.url)\n const restReq: RestRequest = {\n method: c.req.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n json: () => c.req.json<unknown>(),\n }\n\n const res = await handler.handle(restReq)\n // `RestResponse.body` is `string | Uint8Array | null`, all valid BodyInit.\n return new Response(res.body as BodyInit | null, {\n status: res.status,\n headers: res.headers,\n })\n })\n\n return app\n}\n"],"mappings":";AAAA,SAAS,YAAY;AAGd,SAAS,YAAY,SAAiC;AAC3D,QAAM,MAAM,IAAI,KAAK;AAKrB,MAAI,IAAI,KAAK,OAAO,MAAM;AACxB,UAAM,UAAkC,CAAC;AACzC,MAAE,IAAI,IAAI,QAAQ,QAAQ,CAAC,GAAG,MAAM;AAAE,cAAQ,CAAC,IAAI;AAAA,IAAE,CAAC;AAEtD,UAAM,MAAM,IAAI,IAAI,EAAE,IAAI,GAAG;AAC7B,UAAM,UAAuB;AAAA,MAC3B,QAAQ,EAAE,IAAI;AAAA,MACd,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,MAAM,EAAE,IAAI,KAAc;AAAA,IAClC;AAEA,UAAM,MAAM,MAAM,QAAQ,OAAO,OAAO;AAExC,WAAO,IAAI,SAAS,IAAI,MAAyB;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ,SAAS,IAAI;AAAA,IACf,CAAC;AAAA,EACH,CAAC;AAED,SAAO;AACT;","names":[]}
@@ -0,0 +1,65 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/adapters/nitro.ts
21
+ var nitro_exports = {};
22
+ __export(nitro_exports, {
23
+ nitroAdapter: () => nitroAdapter
24
+ });
25
+ module.exports = __toCommonJS(nitro_exports);
26
+ function nitroAdapter(handler) {
27
+ return async function eventHandler(event) {
28
+ const headers = {};
29
+ if (event.headers instanceof Headers) {
30
+ event.headers.forEach((v, k) => {
31
+ headers[k.toLowerCase()] = v;
32
+ });
33
+ } else {
34
+ for (const [k, v] of Object.entries(event.headers)) {
35
+ headers[k.toLowerCase()] = v;
36
+ }
37
+ }
38
+ const url = new URL(event.path, "http://localhost");
39
+ let bodyCache;
40
+ let bodyRead = false;
41
+ const restReq = {
42
+ method: event.method,
43
+ pathname: url.pathname,
44
+ searchParams: url.searchParams,
45
+ headers,
46
+ async json() {
47
+ if (!bodyRead) {
48
+ bodyCache = event._body ?? null;
49
+ bodyRead = true;
50
+ }
51
+ return bodyCache;
52
+ }
53
+ };
54
+ const res = await handler.handle(restReq);
55
+ return new Response(res.body, {
56
+ status: res.status,
57
+ headers: res.headers
58
+ });
59
+ };
60
+ }
61
+ // Annotate the CommonJS export names for ESM import in node:
62
+ 0 && (module.exports = {
63
+ nitroAdapter
64
+ });
65
+ //# sourceMappingURL=nitro.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/nitro.ts"],"sourcesContent":["import type { NoydbRestHandler, RestRequest } from '../index.js'\n\ninterface H3Event {\n method: string\n path: string\n headers: Headers | Record<string, string>\n _body?: unknown\n}\n\n/**\n * Nitro / H3 adapter. Returns a Fetch-spec `Response` — both h3 v1 and v2\n * relay a returned `Response` to the underlying HTTP layer, preserving\n * status, headers, and body (including `Uint8Array`). Returning the raw\n * `RestResponse` shape would be JSON-stringified by h3 and the status\n * would default to 200, which is wrong.\n */\nexport function nitroAdapter(handler: NoydbRestHandler) {\n // No explicit try/catch — Nitro's `defineEventHandler` wraps the\n // returned function and converts any thrown error into a 500 via\n // h3's `createError` path. Contrast with the Express adapter, which\n // needs `next(err)`.\n return async function eventHandler(event: H3Event): Promise<Response> {\n // Normalize headers to lowercase — consistent with Hono / Express /\n // Fastify and with Node's IncomingMessage.headers convention.\n const headers: Record<string, string> = {}\n if (event.headers instanceof Headers) {\n event.headers.forEach((v, k) => { headers[k.toLowerCase()] = v })\n } else {\n for (const [k, v] of Object.entries(event.headers)) {\n headers[k.toLowerCase()] = v\n }\n }\n\n const url = new URL(event.path, 'http://localhost')\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: event.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n async json() {\n if (!bodyRead) { bodyCache = event._body ?? null; bodyRead = true }\n return bodyCache\n },\n }\n\n const res = await handler.handle(restReq)\n // `RestResponse.body` is `string | Uint8Array | null`, all of which are\n // valid `BodyInit`. TS's generic-parameter drift on Uint8Array under\n // lib.es5 requires the cast; the runtime assignment is safe.\n return new Response(res.body as BodyInit | null, {\n status: res.status,\n headers: res.headers,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAgBO,SAAS,aAAa,SAA2B;AAKtD,SAAO,eAAe,aAAa,OAAmC;AAGpE,UAAM,UAAkC,CAAC;AACzC,QAAI,MAAM,mBAAmB,SAAS;AACpC,YAAM,QAAQ,QAAQ,CAAC,GAAG,MAAM;AAAE,gBAAQ,EAAE,YAAY,CAAC,IAAI;AAAA,MAAE,CAAC;AAAA,IAClE,OAAO;AACL,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,MAAM,OAAO,GAAG;AAClD,gBAAQ,EAAE,YAAY,CAAC,IAAI;AAAA,MAC7B;AAAA,IACF;AAEA,UAAM,MAAM,IAAI,IAAI,MAAM,MAAM,kBAAkB;AAClD,QAAI;AACJ,QAAI,WAAW;AAEf,UAAM,UAAuB;AAAA,MAC3B,QAAQ,MAAM;AAAA,MACd,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,OAAO;AACX,YAAI,CAAC,UAAU;AAAE,sBAAY,MAAM,SAAS;AAAM,qBAAW;AAAA,QAAK;AAClE,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,MAAM,MAAM,QAAQ,OAAO,OAAO;AAIxC,WAAO,IAAI,SAAS,IAAI,MAAyB;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ,SAAS,IAAI;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}
@@ -0,0 +1,19 @@
1
+ import { NoydbRestHandler } from '../index.cjs';
2
+ import '@noy-db/hub';
3
+
4
+ interface H3Event {
5
+ method: string;
6
+ path: string;
7
+ headers: Headers | Record<string, string>;
8
+ _body?: unknown;
9
+ }
10
+ /**
11
+ * Nitro / H3 adapter. Returns a Fetch-spec `Response` — both h3 v1 and v2
12
+ * relay a returned `Response` to the underlying HTTP layer, preserving
13
+ * status, headers, and body (including `Uint8Array`). Returning the raw
14
+ * `RestResponse` shape would be JSON-stringified by h3 and the status
15
+ * would default to 200, which is wrong.
16
+ */
17
+ declare function nitroAdapter(handler: NoydbRestHandler): (event: H3Event) => Promise<Response>;
18
+
19
+ export { nitroAdapter };
@@ -0,0 +1,19 @@
1
+ import { NoydbRestHandler } from '../index.js';
2
+ import '@noy-db/hub';
3
+
4
+ interface H3Event {
5
+ method: string;
6
+ path: string;
7
+ headers: Headers | Record<string, string>;
8
+ _body?: unknown;
9
+ }
10
+ /**
11
+ * Nitro / H3 adapter. Returns a Fetch-spec `Response` — both h3 v1 and v2
12
+ * relay a returned `Response` to the underlying HTTP layer, preserving
13
+ * status, headers, and body (including `Uint8Array`). Returning the raw
14
+ * `RestResponse` shape would be JSON-stringified by h3 and the status
15
+ * would default to 200, which is wrong.
16
+ */
17
+ declare function nitroAdapter(handler: NoydbRestHandler): (event: H3Event) => Promise<Response>;
18
+
19
+ export { nitroAdapter };
@@ -0,0 +1,40 @@
1
+ // src/adapters/nitro.ts
2
+ function nitroAdapter(handler) {
3
+ return async function eventHandler(event) {
4
+ const headers = {};
5
+ if (event.headers instanceof Headers) {
6
+ event.headers.forEach((v, k) => {
7
+ headers[k.toLowerCase()] = v;
8
+ });
9
+ } else {
10
+ for (const [k, v] of Object.entries(event.headers)) {
11
+ headers[k.toLowerCase()] = v;
12
+ }
13
+ }
14
+ const url = new URL(event.path, "http://localhost");
15
+ let bodyCache;
16
+ let bodyRead = false;
17
+ const restReq = {
18
+ method: event.method,
19
+ pathname: url.pathname,
20
+ searchParams: url.searchParams,
21
+ headers,
22
+ async json() {
23
+ if (!bodyRead) {
24
+ bodyCache = event._body ?? null;
25
+ bodyRead = true;
26
+ }
27
+ return bodyCache;
28
+ }
29
+ };
30
+ const res = await handler.handle(restReq);
31
+ return new Response(res.body, {
32
+ status: res.status,
33
+ headers: res.headers
34
+ });
35
+ };
36
+ }
37
+ export {
38
+ nitroAdapter
39
+ };
40
+ //# sourceMappingURL=nitro.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/adapters/nitro.ts"],"sourcesContent":["import type { NoydbRestHandler, RestRequest } from '../index.js'\n\ninterface H3Event {\n method: string\n path: string\n headers: Headers | Record<string, string>\n _body?: unknown\n}\n\n/**\n * Nitro / H3 adapter. Returns a Fetch-spec `Response` — both h3 v1 and v2\n * relay a returned `Response` to the underlying HTTP layer, preserving\n * status, headers, and body (including `Uint8Array`). Returning the raw\n * `RestResponse` shape would be JSON-stringified by h3 and the status\n * would default to 200, which is wrong.\n */\nexport function nitroAdapter(handler: NoydbRestHandler) {\n // No explicit try/catch — Nitro's `defineEventHandler` wraps the\n // returned function and converts any thrown error into a 500 via\n // h3's `createError` path. Contrast with the Express adapter, which\n // needs `next(err)`.\n return async function eventHandler(event: H3Event): Promise<Response> {\n // Normalize headers to lowercase — consistent with Hono / Express /\n // Fastify and with Node's IncomingMessage.headers convention.\n const headers: Record<string, string> = {}\n if (event.headers instanceof Headers) {\n event.headers.forEach((v, k) => { headers[k.toLowerCase()] = v })\n } else {\n for (const [k, v] of Object.entries(event.headers)) {\n headers[k.toLowerCase()] = v\n }\n }\n\n const url = new URL(event.path, 'http://localhost')\n let bodyCache: unknown\n let bodyRead = false\n\n const restReq: RestRequest = {\n method: event.method,\n pathname: url.pathname,\n searchParams: url.searchParams,\n headers,\n async json() {\n if (!bodyRead) { bodyCache = event._body ?? null; bodyRead = true }\n return bodyCache\n },\n }\n\n const res = await handler.handle(restReq)\n // `RestResponse.body` is `string | Uint8Array | null`, all of which are\n // valid `BodyInit`. TS's generic-parameter drift on Uint8Array under\n // lib.es5 requires the cast; the runtime assignment is safe.\n return new Response(res.body as BodyInit | null, {\n status: res.status,\n headers: res.headers,\n })\n }\n}\n"],"mappings":";AAgBO,SAAS,aAAa,SAA2B;AAKtD,SAAO,eAAe,aAAa,OAAmC;AAGpE,UAAM,UAAkC,CAAC;AACzC,QAAI,MAAM,mBAAmB,SAAS;AACpC,YAAM,QAAQ,QAAQ,CAAC,GAAG,MAAM;AAAE,gBAAQ,EAAE,YAAY,CAAC,IAAI;AAAA,MAAE,CAAC;AAAA,IAClE,OAAO;AACL,iBAAW,CAAC,GAAG,CAAC,KAAK,OAAO,QAAQ,MAAM,OAAO,GAAG;AAClD,gBAAQ,EAAE,YAAY,CAAC,IAAI;AAAA,MAC7B;AAAA,IACF;AAEA,UAAM,MAAM,IAAI,IAAI,MAAM,MAAM,kBAAkB;AAClD,QAAI;AACJ,QAAI,WAAW;AAEf,UAAM,UAAuB;AAAA,MAC3B,QAAQ,MAAM;AAAA,MACd,UAAU,IAAI;AAAA,MACd,cAAc,IAAI;AAAA,MAClB;AAAA,MACA,MAAM,OAAO;AACX,YAAI,CAAC,UAAU;AAAE,sBAAY,MAAM,SAAS;AAAM,qBAAW;AAAA,QAAK;AAClE,eAAO;AAAA,MACT;AAAA,IACF;AAEA,UAAM,MAAM,MAAM,QAAQ,OAAO,OAAO;AAIxC,WAAO,IAAI,SAAS,IAAI,MAAyB;AAAA,MAC/C,QAAQ,IAAI;AAAA,MACZ,SAAS,IAAI;AAAA,IACf,CAAC;AAAA,EACH;AACF;","names":[]}