@sourceregistry/node-webserver 1.5.0 → 1.6.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/dist/index.es.js CHANGED
@@ -31,7 +31,7 @@ function T(e) {
31
31
  }
32
32
  //#endregion
33
33
  //#region src/middlewares/ratelimiter/InMemory.ts
34
- var ee = class {
34
+ var E = class {
35
35
  constructor(e) {
36
36
  this.data = /* @__PURE__ */ new Map(), this.windowMs = e.windowMs, this.startCleanup();
37
37
  }
@@ -57,19 +57,105 @@ var ee = class {
57
57
  async resetAll() {
58
58
  this.data.clear();
59
59
  }
60
- }, E = /* @__PURE__ */ S({ fixedWindowLimit: () => D });
61
- function D(e) {
62
- let { windowMs: t = 6e4, max: n, key: r = (e) => e.getClientAddress(), message: i = "Too many requests, please try again later.", statusCode: a = 429, headers: o = "include", onRateLimit: s, store: c = new ee({ windowMs: t }) } = e;
60
+ }, D = class {
61
+ constructor(e) {
62
+ this.data = /* @__PURE__ */ new Map(), this.windowMs = e.windowMs, this.startCleanup();
63
+ }
64
+ async incr(e) {
65
+ let t = Date.now(), n = t - this.windowMs, r = this.data.get(e) || [];
66
+ r = r.filter((e) => e > n), r.push(t), this.data.set(e, r);
67
+ let i = t + this.windowMs;
68
+ return {
69
+ current: r.length,
70
+ reset: i
71
+ };
72
+ }
73
+ startCleanup() {
74
+ this.cleanupInterval = setInterval(() => {
75
+ let e = Date.now();
76
+ for (let [t, n] of this.data) {
77
+ let r = e - this.windowMs, i = n.filter((e) => e > r);
78
+ i.length === 0 ? this.data.delete(t) : this.data.set(t, i);
79
+ }
80
+ }, Math.min(this.windowMs, 3e5));
81
+ }
82
+ stop() {
83
+ this.cleanupInterval && clearInterval(this.cleanupInterval);
84
+ }
85
+ async resetAll() {
86
+ this.data.clear();
87
+ }
88
+ }, ee = /* @__PURE__ */ S({
89
+ MemoryStore: () => E,
90
+ SlidingWindowStore: () => D,
91
+ fixedWindowLimit: () => te,
92
+ slidingWindowLimit: () => O
93
+ });
94
+ function O(e) {
95
+ let { windowMs: t = 6e4, max: n, key: r = (e) => e.getClientAddress(), message: i = "Too many requests, please try again later.", statusCode: a = 429, headers: o = "include", onRateLimit: s, store: c = new D({ windowMs: t }) } = e;
63
96
  return async (e, t) => {
64
97
  let l = r(e);
65
98
  if (typeof l != "string" || !/^[a-zA-Z0-9_.-]+$/.test(l)) throw Error("Invalid rate limit key: only alphanumeric, underscore, dot, and hyphen allowed");
66
99
  let u = `rl:${l}`, { current: d, reset: f } = await c.incr(u), p = Math.ceil((f - Date.now()) / 1e3);
67
100
  if (d > n) {
68
- s && s(e, {
69
- current: d,
70
- max: n,
71
- key: u
72
- });
101
+ if (s) {
102
+ let t = f - Date.now();
103
+ s(e, {
104
+ current: d,
105
+ max: n,
106
+ key: u,
107
+ reset: Math.floor(f / 1e3),
108
+ remaining: 0,
109
+ resetTimeMs: t
110
+ });
111
+ }
112
+ let t = {
113
+ status: a,
114
+ headers: new Headers()
115
+ }, r = t.headers;
116
+ o === "include" && (r.set("X-RateLimit-Limit", String(n)), r.set("X-RateLimit-Remaining", "0"), r.set("X-RateLimit-Reset", String(Math.floor(f / 1e3))), r.set("Retry-After", String(p)));
117
+ let c;
118
+ return typeof i == "string" ? (c = i, r.set("Content-Type", "text/plain")) : (c = JSON.stringify(i), r.set("Content-Type", "application/json")), new Response(c, t);
119
+ }
120
+ if (e.rateLimit = {
121
+ current: d,
122
+ limit: n,
123
+ reset: new Date(f),
124
+ remaining: n - d
125
+ }, o === "include") {
126
+ let t = {
127
+ "X-RateLimit-Limit": String(n),
128
+ "X-RateLimit-Remaining": String(n - d),
129
+ "X-RateLimit-Reset": String(Math.floor(f / 1e3))
130
+ }, r = e.setHeaders;
131
+ e.setHeaders = (e) => {
132
+ r({
133
+ ...t,
134
+ ...e
135
+ });
136
+ }, r(t);
137
+ }
138
+ return t();
139
+ };
140
+ }
141
+ function te(e) {
142
+ let { windowMs: t = 6e4, max: n, key: r = (e) => e.getClientAddress(), message: i = "Too many requests, please try again later.", statusCode: a = 429, headers: o = "include", onRateLimit: s, store: c = new E({ windowMs: t }) } = e;
143
+ return async (e, t) => {
144
+ let l = r(e);
145
+ if (typeof l != "string" || !/^[a-zA-Z0-9_.-]+$/.test(l)) throw Error("Invalid rate limit key: only alphanumeric, underscore, dot, and hyphen allowed");
146
+ let u = `rl:${l}`, { current: d, reset: f } = await c.incr(u), p = Math.ceil((f - Date.now()) / 1e3);
147
+ if (d > n) {
148
+ if (s) {
149
+ let t = f - Date.now();
150
+ s(e, {
151
+ current: d,
152
+ max: n,
153
+ key: u,
154
+ reset: Math.floor(f / 1e3),
155
+ remaining: 0,
156
+ resetTimeMs: t
157
+ });
158
+ }
73
159
  let t = {
74
160
  status: a,
75
161
  headers: new Headers()
@@ -101,7 +187,7 @@ function D(e) {
101
187
  }
102
188
  //#endregion
103
189
  //#region src/middlewares/cros/index.ts
104
- var te = /* @__PURE__ */ S({ policy: () => j }), ne = [
190
+ var ne = /* @__PURE__ */ S({ policy: () => M }), re = [
105
191
  "GET",
106
192
  "POST",
107
193
  "PUT",
@@ -109,13 +195,13 @@ var te = /* @__PURE__ */ S({ policy: () => j }), ne = [
109
195
  "PATCH",
110
196
  "HEAD",
111
197
  "OPTIONS"
112
- ], re = [
198
+ ], ie = [
113
199
  "Accept",
114
200
  "Accept-Language",
115
201
  "Content-Language",
116
202
  "Content-Type",
117
203
  "Range"
118
- ], O = [
204
+ ], k = [
119
205
  "Authorization",
120
206
  "X-Auth-Token",
121
207
  "X-Requested-With",
@@ -125,21 +211,21 @@ var te = /* @__PURE__ */ S({ policy: () => j }), ne = [
125
211
  "X-Real-IP",
126
212
  "X-Custom-Header"
127
213
  ];
128
- function k(e, t) {
129
- return !e || !t ? !1 : t === "*" ? !0 : t === "null" ? e === "null" : Array.isArray(t) ? t.some((t) => k(e, t)) : typeof t == "function" ? t(e) : t instanceof RegExp ? t.test(e) : e === t;
130
- }
131
214
  function A(e, t) {
215
+ return !e || !t ? !1 : t === "*" ? !0 : t === "null" ? e === "null" : Array.isArray(t) ? t.some((t) => A(e, t)) : typeof t == "function" ? t(e) : t instanceof RegExp ? t.test(e) : e === t;
216
+ }
217
+ function j(e, t) {
132
218
  let { origin: n = "*" } = t;
133
- return e ? n === "*" ? t.credentials ? e : "*" : k(e, n) ? e : null : n === "*" ? "*" : null;
219
+ return e ? n === "*" ? t.credentials ? e : "*" : A(e, n) ? e : null : n === "*" ? "*" : null;
134
220
  }
135
- function j(e = {}) {
136
- let { methods: t = ne, allowedHeaders: n = O, exposedHeaders: r, credentials: i = !1, maxAge: a = 86400, onResponse: o } = e, s = t.join(","), c = [...re, ...n].join(","), l = [
221
+ function M(e = {}) {
222
+ let { methods: t = re, allowedHeaders: n = k, exposedHeaders: r, credentials: i = !1, maxAge: a = 86400, onResponse: o } = e, s = t.join(","), c = [...ie, ...n].join(","), l = [
137
223
  ["Vary", "Origin,Access-Control-Request-Method,Access-Control-Request-Headers"],
138
224
  ["Access-Control-Allow-Methods", s],
139
225
  ["Access-Control-Allow-Headers", c]
140
226
  ];
141
227
  return r && l.push(["Access-Control-Expose-Headers", r.join(",")]), i && l.push(["Access-Control-Allow-Credentials", "true"]), a && l.push(["Access-Control-Max-Age", a.toString()]), async (t, n) => {
142
- let r = t.request, i = r.headers.get("Origin"), a = r.method === "OPTIONS" && i !== null && r.headers.has("Access-Control-Request-Method"), s = A(i, e);
228
+ let r = t.request, i = r.headers.get("Origin"), a = r.method === "OPTIONS" && i !== null && r.headers.has("Access-Control-Request-Method"), s = j(i, e);
143
229
  if (a) {
144
230
  if (!s) return new Response(null, { status: 403 });
145
231
  let e = new Response(null, { status: 204 });
@@ -162,7 +248,7 @@ function j(e = {}) {
162
248
  }
163
249
  //#endregion
164
250
  //#region src/middlewares/security/index.ts
165
- var M = /* @__PURE__ */ S({ headers: () => P }), N = {
251
+ var N = /* @__PURE__ */ S({ headers: () => F }), P = {
166
252
  contentSecurityPolicy: "default-src 'self'; base-uri 'self'; frame-ancestors 'none'; object-src 'none'",
167
253
  frameOptions: "DENY",
168
254
  referrerPolicy: "no-referrer",
@@ -171,36 +257,36 @@ var M = /* @__PURE__ */ S({ headers: () => P }), N = {
171
257
  crossOriginResourcePolicy: "same-origin",
172
258
  strictTransportSecurity: !1
173
259
  };
174
- function P(e = {}) {
260
+ function F(e = {}) {
175
261
  let t = {
176
- ...N,
262
+ ...P,
177
263
  ...e
178
264
  };
179
265
  return async (e, n) => {
180
266
  let r = await n();
181
267
  if (!r) return;
182
268
  let i = new Headers(r.headers);
183
- return F(i, "content-security-policy", t.contentSecurityPolicy), F(i, "x-frame-options", t.frameOptions), F(i, "referrer-policy", t.referrerPolicy), F(i, "permissions-policy", t.permissionsPolicy), F(i, "cross-origin-opener-policy", t.crossOriginOpenerPolicy), F(i, "cross-origin-resource-policy", t.crossOriginResourcePolicy), F(i, "strict-transport-security", t.strictTransportSecurity), new Response(r.body, {
269
+ return I(i, "content-security-policy", t.contentSecurityPolicy), I(i, "x-frame-options", t.frameOptions), I(i, "referrer-policy", t.referrerPolicy), I(i, "permissions-policy", t.permissionsPolicy), I(i, "cross-origin-opener-policy", t.crossOriginOpenerPolicy), I(i, "cross-origin-resource-policy", t.crossOriginResourcePolicy), I(i, "strict-transport-security", t.strictTransportSecurity), new Response(r.body, {
184
270
  status: r.status,
185
271
  statusText: r.statusText,
186
272
  headers: i
187
273
  });
188
274
  };
189
275
  }
190
- function F(e, t, n) {
276
+ function I(e, t, n) {
191
277
  !n || e.has(t) || e.set(t, n);
192
278
  }
193
279
  //#endregion
194
280
  //#region src/middlewares/requestid/index.ts
195
- var I = /* @__PURE__ */ S({ assign: () => L });
196
- function L(t = {}) {
281
+ var L = /* @__PURE__ */ S({ assign: () => R });
282
+ function R(t = {}) {
197
283
  let n = t.headerName?.toLowerCase() ?? "x-request-id", r = t.generate ?? e, i = t.clientRequestId ?? !1;
198
284
  return async (e, t) => {
199
285
  let a = e.request.headers.get(n) ?? r();
200
286
  if (i) {
201
287
  let t = e.request.headers.get("x-client-request-id");
202
288
  if (t !== null) {
203
- if (!R(t) || t.length > 512) return new Response("Invalid X-Client-Request-Id header", { status: 400 });
289
+ if (!z(t) || t.length > 512) return new Response("Invalid X-Client-Request-Id header", { status: 400 });
204
290
  a = t;
205
291
  }
206
292
  }
@@ -216,13 +302,13 @@ function L(t = {}) {
216
302
  });
217
303
  };
218
304
  }
219
- function R(e) {
305
+ function z(e) {
220
306
  return /^[\x00-\x7F]*$/.test(e);
221
307
  }
222
308
  //#endregion
223
309
  //#region src/middlewares/timeout/index.ts
224
- var z = /* @__PURE__ */ S({ deadline: () => B });
225
- function B(e) {
310
+ var B = /* @__PURE__ */ S({ deadline: () => V });
311
+ function V(e) {
226
312
  let { ms: t, status: n = 504, body: r = "Gateway Timeout", onTimeout: i } = e;
227
313
  if (!Number.isFinite(t) || t <= 0) throw TypeError("Timeout.deadline requires a positive ms value");
228
314
  return async (e, a) => {
@@ -247,7 +333,7 @@ function B(e) {
247
333
  }
248
334
  //#endregion
249
335
  //#region src/types/RequestMethod.ts
250
- var V = [
336
+ var H = [
251
337
  "GET",
252
338
  "PUT",
253
339
  "POST",
@@ -255,7 +341,7 @@ var V = [
255
341
  "PATCH",
256
342
  "HEAD",
257
343
  "OPTIONS"
258
- ], H = class {
344
+ ], U = class {
259
345
  static {
260
346
  this.cache = /* @__PURE__ */ new Map();
261
347
  }
@@ -265,7 +351,7 @@ var V = [
265
351
  static set(e, t) {
266
352
  this.cache.set(e, t);
267
353
  }
268
- }, U = class {
354
+ }, W = class {
269
355
  constructor() {
270
356
  this._routes = [], this._wsRoutes = [], this._nestedRouters = [], this._middlewares = [], this._preHandlers = [], this._postHandlers = [], this.routesSorted = !1, this.wsRoutesSorted = !1;
271
357
  }
@@ -297,7 +383,7 @@ var V = [
297
383
  return this.addHandler("OPTIONS", e, t, n);
298
384
  }
299
385
  USE(e, t, ...n) {
300
- return V.forEach((r) => this.addHandler(r, e, t, n)), this;
386
+ return H.forEach((r) => this.addHandler(r, e, t, n)), this;
301
387
  }
302
388
  action(e, t, ...n) {
303
389
  return this.addHandler("POST", e, async (e) => {
@@ -453,7 +539,7 @@ var V = [
453
539
  }), this.routesSorted = !1, this;
454
540
  }
455
541
  createPathRegex(e) {
456
- let t = H.get(e);
542
+ let t = U.get(e);
457
543
  if (t) return t;
458
544
  let n = [], r = !1, i, a = e.split("/").filter(Boolean);
459
545
  i = a.reduce((e, t) => t.startsWith("[...") ? e - 10 : t.startsWith("[[") ? e - 5 : t.startsWith("[") ? e - 1 : e + 1, 0);
@@ -476,7 +562,7 @@ var V = [
476
562
  isCatchAll: r,
477
563
  priority: i
478
564
  };
479
- return H.set(e, s), s;
565
+ return U.set(e, s), s;
480
566
  }
481
567
  createPrefixRegex(e) {
482
568
  let t = [], n = !1, r, i = e.split("/").filter(Boolean);
@@ -569,17 +655,17 @@ var V = [
569
655
  this._wsRoutes.sort((e, t) => t.priority - e.priority), this.wsRoutesSorted = !0;
570
656
  }
571
657
  formatActionResult(e) {
572
- return e instanceof Response ? e : e?.type === "failure" && "status" in e ? W.fail(e.status, e.data) : W.success(200, e ?? void 0);
658
+ return e instanceof Response ? e : e?.type === "failure" && "status" in e ? G.fail(e.status, e.data) : G.success(200, e ?? void 0);
573
659
  }
574
660
  handleActionError(e) {
575
- if (C(e)) return W.error(e.status, { message: e.statusText || "Error" });
661
+ if (C(e)) return G.error(e.status, { message: e.statusText || "Error" });
576
662
  if (w(e)) {
577
663
  let t = e.headers.get("Location") || "/";
578
- return W.redirect(e.status, t);
664
+ return G.redirect(e.status, t);
579
665
  }
580
- return console.error(e), W.error(500, { message: "Internal Server Error" });
666
+ return console.error(e), G.error(500, { message: "Internal Server Error" });
581
667
  }
582
- }, W = {
668
+ }, G = {
583
669
  success: (e = 200, t) => new Response(JSON.stringify({
584
670
  data: t,
585
671
  type: "success",
@@ -612,7 +698,7 @@ var V = [
612
698
  status: e,
613
699
  headers: { "Content-Type": "application/json" }
614
700
  })
615
- }, G = class {
701
+ }, K = class {
616
702
  constructor(e, t) {
617
703
  this.raw = e.headers.get("cookie") ?? "", this.setCookieHeader = t;
618
704
  }
@@ -634,11 +720,11 @@ var V = [
634
720
  maxAge: 0
635
721
  });
636
722
  }
637
- }, K = class extends Error {
723
+ }, q = class extends Error {
638
724
  constructor(e = "Payload Too Large") {
639
725
  super(e), this.status = 413, this.name = "PayloadTooLargeError";
640
726
  }
641
- }, q = class extends U {
727
+ }, J = class extends W {
642
728
  constructor(e) {
643
729
  super(), this.upgradeHandlerInstalled = !1, this.config = e ?? {
644
730
  type: "http",
@@ -748,7 +834,7 @@ var V = [
748
834
  if (!t) return e;
749
835
  let n = 0, r = new a({ transform(e, r, i) {
750
836
  if (n += Buffer.byteLength(e), n > t) {
751
- i(new K());
837
+ i(new q());
752
838
  return;
753
839
  }
754
840
  i(null, e);
@@ -855,7 +941,7 @@ var V = [
855
941
  return Number.isFinite(r) && r <= t;
856
942
  }
857
943
  handleError(e) {
858
- if (e instanceof K) return new Response(e.message, { status: e.status });
944
+ if (e instanceof q) return new Response(e.message, { status: e.status });
859
945
  if (C(e)) return new Response(JSON.stringify({
860
946
  error: e.statusText || "Error",
861
947
  status: e.status
@@ -953,7 +1039,7 @@ var V = [
953
1039
  r && t.set(n, r);
954
1040
  }
955
1041
  toRequestEvent(e, t, n) {
956
- let r = new G(e, n.pushSetCookie), i = this.config, a = {}, o = {
1042
+ let r = new K(e, n.pushSetCookie), i = this.config, a = {}, o = {
957
1043
  name: "node-webserver",
958
1044
  dev: this.isDevelopment()
959
1045
  }, s = /* @__PURE__ */ new Set(), c = {
@@ -981,7 +1067,7 @@ var V = [
981
1067
  }, l = this.createEventFetch(c, n);
982
1068
  return i.locals && Object.assign(a, i.locals(c)), i.platform && Object.assign(o, i.platform(c)), c;
983
1069
  }
984
- }, J = {
1070
+ }, Y = {
985
1071
  ".avif": "image/avif",
986
1072
  ".css": "text/css; charset=utf-8",
987
1073
  ".gif": "image/gif",
@@ -999,24 +1085,24 @@ var V = [
999
1085
  ".wasm": "application/wasm",
1000
1086
  ".webp": "image/webp",
1001
1087
  ".xml": "application/xml; charset=utf-8"
1002
- }, Y = {
1088
+ }, ae = {
1003
1089
  index: "index.html",
1004
1090
  cacheControl: "public, max-age=0",
1005
1091
  dotFiles: "ignore"
1006
1092
  };
1007
1093
  async function X(e, t, n = {}) {
1008
- let r = se(t), i = {
1009
- ...Y,
1094
+ let r = ue(t), i = {
1095
+ ...ae,
1010
1096
  ...n
1011
- }, a = await ie(e), o = ae(r, i.dotFiles);
1097
+ }, a = await oe(e), o = se(r, i.dotFiles);
1012
1098
  if (o instanceof Response) return o;
1013
1099
  let s = v(a, o.length > 0 ? o.join(y) : "");
1014
1100
  if (!Q(a, s)) return new Response("Forbidden", { status: 403 });
1015
- let c = await oe(s, a, i.index);
1101
+ let c = await ce(s, a, i.index);
1016
1102
  if (c instanceof Response) return c;
1017
1103
  let l = await m(c), u = new Headers({
1018
1104
  "content-length": String(l.size),
1019
- "content-type": $(c),
1105
+ "content-type": le(c),
1020
1106
  "cache-control": i.cacheControl,
1021
1107
  "last-modified": l.mtime.toUTCString(),
1022
1108
  "x-content-type-options": "nosniff"
@@ -1032,10 +1118,10 @@ async function X(e, t, n = {}) {
1032
1118
  headers: u
1033
1119
  });
1034
1120
  }
1035
- async function ie(e) {
1121
+ async function oe(e) {
1036
1122
  return p(e);
1037
1123
  }
1038
- function ae(e, t) {
1124
+ function se(e, t) {
1039
1125
  if (e.includes("\0")) return new Response("Bad Request", { status: 400 });
1040
1126
  let n = e.replace(/\\/g, "/").split("/").filter(Boolean), r = [];
1041
1127
  for (let e of n) {
@@ -1056,7 +1142,7 @@ function ae(e, t) {
1056
1142
  }
1057
1143
  return r;
1058
1144
  }
1059
- async function oe(e, t, n) {
1145
+ async function ce(e, t, n) {
1060
1146
  try {
1061
1147
  return (await f(e)).isDirectory() ? Z(v(e, n), t) : Z(e, t);
1062
1148
  } catch {
@@ -1075,13 +1161,13 @@ function Q(e, t) {
1075
1161
  let n = _(e, t);
1076
1162
  return n === "" || !n.startsWith("..") && !g(n);
1077
1163
  }
1078
- function $(e) {
1079
- return J[h(e).toLowerCase()] ?? "application/octet-stream";
1164
+ function le(e) {
1165
+ return Y[h(e).toLowerCase()] ?? "application/octet-stream";
1080
1166
  }
1081
- function se(e) {
1167
+ function ue(e) {
1082
1168
  return typeof e.params.path == "string" ? e.params.path : e.url.pathname.replace(/^\/+/, "");
1083
1169
  }
1084
- var ce = (e, t = {}) => (n) => X(e, n, t), le = (e, ...t) => async (n) => {
1170
+ var de = (e, t = {}) => (n) => X(e, n, t), fe = (e, ...t) => async (n) => {
1085
1171
  let r = {};
1086
1172
  for (let e of t) {
1087
1173
  let t = await e(n);
@@ -1092,7 +1178,7 @@ var ce = (e, t = {}) => (n) => X(e, n, t), le = (e, ...t) => async (n) => {
1092
1178
  };
1093
1179
  //#endregion
1094
1180
  //#region src/helpers/sse.ts
1095
- function ue(e, t = {}) {
1181
+ function pe(e, t = {}) {
1096
1182
  let n = [];
1097
1183
  if (t.comment) {
1098
1184
  let e = t.comment.replace(/\r\n/g, " ").replace(/\r/g, " ").replace(/\n/g, " ");
@@ -1104,7 +1190,7 @@ function ue(e, t = {}) {
1104
1190
  }
1105
1191
  return `${n.join("\n")}\n\n`;
1106
1192
  }
1107
- var de = (e, t = {}) => (n) => {
1193
+ var $ = (e, t = {}) => (n) => {
1108
1194
  let r = new TextEncoder(), i = null, a = !1, o, s = async () => {
1109
1195
  if (!a) {
1110
1196
  a = !0;
@@ -1120,7 +1206,7 @@ var de = (e, t = {}) => (n) => {
1120
1206
  async start(t) {
1121
1207
  i = t;
1122
1208
  let c = (e, n = {}) => {
1123
- a || t.enqueue(r.encode(ue(e, n)));
1209
+ a || t.enqueue(r.encode(pe(e, n)));
1124
1210
  };
1125
1211
  n.request.signal.addEventListener("abort", () => {
1126
1212
  s();
@@ -1148,7 +1234,7 @@ var de = (e, t = {}) => (n) => {
1148
1234
  ...t.headers
1149
1235
  }
1150
1236
  });
1151
- }, fe = async (e, t) => {
1237
+ }, me = async (e, t) => {
1152
1238
  let n = JSON.stringify(await e);
1153
1239
  return new Response(n, {
1154
1240
  ...t,
@@ -1159,19 +1245,19 @@ var de = (e, t = {}) => (n) => {
1159
1245
  }
1160
1246
  });
1161
1247
  };
1162
- function pe(e, t) {
1248
+ function he(e, t) {
1163
1249
  throw new Response(null, {
1164
1250
  status: e,
1165
1251
  headers: { location: t.toString() }
1166
1252
  });
1167
1253
  }
1168
- function me(e, t) {
1254
+ function ge(e, t) {
1169
1255
  throw new Response(JSON.stringify(typeof t == "string" ? { message: t } : t), {
1170
1256
  status: e,
1171
1257
  headers: { "content-type": "application/json" }
1172
1258
  });
1173
1259
  }
1174
- var he = async (e, t) => {
1260
+ var _e = async (e, t) => {
1175
1261
  let n = await e;
1176
1262
  return new Response(n, {
1177
1263
  ...t,
@@ -1181,7 +1267,7 @@ var he = async (e, t) => {
1181
1267
  ...t?.headers
1182
1268
  }
1183
1269
  });
1184
- }, ge = async (e, t) => {
1270
+ }, ve = async (e, t) => {
1185
1271
  let n = await e;
1186
1272
  return new Response(n, {
1187
1273
  ...t,
@@ -1193,6 +1279,6 @@ var he = async (e, t) => {
1193
1279
  });
1194
1280
  };
1195
1281
  //#endregion
1196
- export { W as Action, te as CORS, E as RateLimiter, I as RequestId, V as RequestMethods, U as Router, M as Security, z as Timeout, q as WebServer, ce as dir, le as enhance, me as error, ge as html, C as isHttpError, w as isRedirect, T as isResponse, fe as json, pe as redirect, X as serveStatic, de as sse, he as text };
1282
+ export { G as Action, ne as CORS, ee as RateLimiter, L as RequestId, H as RequestMethods, W as Router, N as Security, B as Timeout, J as WebServer, de as dir, fe as enhance, ge as error, ve as html, C as isHttpError, w as isRedirect, T as isResponse, me as json, he as redirect, X as serveStatic, $ as sse, _e as text };
1197
1283
 
1198
1284
  //# sourceMappingURL=index.es.js.map