@sourceregistry/node-webserver 1.5.0 → 1.6.1

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);
@@ -517,21 +603,36 @@ var V = [
517
603
  return r;
518
604
  }
519
605
  async handleNestedRouters(e, t) {
520
- let n = [...this._nestedRouters].sort((e, t) => t.priority - e.priority);
521
- for (let r of n) {
522
- let n = t.match(r.regex);
606
+ let n = [...this._nestedRouters].sort((e, t) => t.priority - e.priority), r = e.request.method;
607
+ for (let i of n) {
608
+ let n = t.match(i.regex);
523
609
  if (!n || n.index !== 0) continue;
524
- let i = n[0], a = t.slice(i.length) || "/", o = this.extractPrefixParams(r, i), s = {
610
+ let a = n[0], o = t.slice(a.length) || "/";
611
+ if (!i.router.hasHttpMatchAtPath(r, o)) continue;
612
+ let s = this.extractPrefixParams(i, a), c = {
525
613
  ...e,
526
614
  params: {
527
615
  ...e.params,
528
- ...o
616
+ ...s
529
617
  }
530
- }, c = await this.applyMiddlewaresWithList(s, r.middlewares, async () => await r.router.handleAtPath(s, a));
531
- if (c) return c;
618
+ }, l = await this.applyMiddlewaresWithList(c, i.middlewares, async () => await i.router.handleAtPath(c, o));
619
+ if (l) return l;
532
620
  }
533
621
  return null;
534
622
  }
623
+ hasHttpMatchAtPath(e, t) {
624
+ if (this.hasLocalPathMatch(t, e)) return !0;
625
+ for (let n of this._nestedRouters) {
626
+ let r = t.match(n.regex);
627
+ if (!r || r.index !== 0) continue;
628
+ let i = r[0], a = t.slice(i.length) || "/";
629
+ if (n.router.hasHttpMatchAtPath(e, a)) return !0;
630
+ }
631
+ return !1;
632
+ }
633
+ hasLocalPathMatch(e, t) {
634
+ return this._routes.some((n) => n.regex.test(e) ? t === "HEAD" ? n.method === "HEAD" || n.method === "GET" : !0 : !1);
635
+ }
535
636
  async handleLocalRoutes(e, t, n) {
536
637
  let r = /* @__PURE__ */ new Set(), i = !1;
537
638
  for (let a of this._routes) {
@@ -569,17 +670,17 @@ var V = [
569
670
  this._wsRoutes.sort((e, t) => t.priority - e.priority), this.wsRoutesSorted = !0;
570
671
  }
571
672
  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);
673
+ return e instanceof Response ? e : e?.type === "failure" && "status" in e ? G.fail(e.status, e.data) : G.success(200, e ?? void 0);
573
674
  }
574
675
  handleActionError(e) {
575
- if (C(e)) return W.error(e.status, { message: e.statusText || "Error" });
676
+ if (C(e)) return G.error(e.status, { message: e.statusText || "Error" });
576
677
  if (w(e)) {
577
678
  let t = e.headers.get("Location") || "/";
578
- return W.redirect(e.status, t);
679
+ return G.redirect(e.status, t);
579
680
  }
580
- return console.error(e), W.error(500, { message: "Internal Server Error" });
681
+ return console.error(e), G.error(500, { message: "Internal Server Error" });
581
682
  }
582
- }, W = {
683
+ }, G = {
583
684
  success: (e = 200, t) => new Response(JSON.stringify({
584
685
  data: t,
585
686
  type: "success",
@@ -612,7 +713,7 @@ var V = [
612
713
  status: e,
613
714
  headers: { "Content-Type": "application/json" }
614
715
  })
615
- }, G = class {
716
+ }, K = class {
616
717
  constructor(e, t) {
617
718
  this.raw = e.headers.get("cookie") ?? "", this.setCookieHeader = t;
618
719
  }
@@ -634,11 +735,11 @@ var V = [
634
735
  maxAge: 0
635
736
  });
636
737
  }
637
- }, K = class extends Error {
738
+ }, q = class extends Error {
638
739
  constructor(e = "Payload Too Large") {
639
740
  super(e), this.status = 413, this.name = "PayloadTooLargeError";
640
741
  }
641
- }, q = class extends U {
742
+ }, J = class extends W {
642
743
  constructor(e) {
643
744
  super(), this.upgradeHandlerInstalled = !1, this.config = e ?? {
644
745
  type: "http",
@@ -748,7 +849,7 @@ var V = [
748
849
  if (!t) return e;
749
850
  let n = 0, r = new a({ transform(e, r, i) {
750
851
  if (n += Buffer.byteLength(e), n > t) {
751
- i(new K());
852
+ i(new q());
752
853
  return;
753
854
  }
754
855
  i(null, e);
@@ -855,7 +956,7 @@ var V = [
855
956
  return Number.isFinite(r) && r <= t;
856
957
  }
857
958
  handleError(e) {
858
- if (e instanceof K) return new Response(e.message, { status: e.status });
959
+ if (e instanceof q) return new Response(e.message, { status: e.status });
859
960
  if (C(e)) return new Response(JSON.stringify({
860
961
  error: e.statusText || "Error",
861
962
  status: e.status
@@ -953,7 +1054,7 @@ var V = [
953
1054
  r && t.set(n, r);
954
1055
  }
955
1056
  toRequestEvent(e, t, n) {
956
- let r = new G(e, n.pushSetCookie), i = this.config, a = {}, o = {
1057
+ let r = new K(e, n.pushSetCookie), i = this.config, a = {}, o = {
957
1058
  name: "node-webserver",
958
1059
  dev: this.isDevelopment()
959
1060
  }, s = /* @__PURE__ */ new Set(), c = {
@@ -981,7 +1082,7 @@ var V = [
981
1082
  }, l = this.createEventFetch(c, n);
982
1083
  return i.locals && Object.assign(a, i.locals(c)), i.platform && Object.assign(o, i.platform(c)), c;
983
1084
  }
984
- }, J = {
1085
+ }, Y = {
985
1086
  ".avif": "image/avif",
986
1087
  ".css": "text/css; charset=utf-8",
987
1088
  ".gif": "image/gif",
@@ -999,24 +1100,24 @@ var V = [
999
1100
  ".wasm": "application/wasm",
1000
1101
  ".webp": "image/webp",
1001
1102
  ".xml": "application/xml; charset=utf-8"
1002
- }, Y = {
1103
+ }, ae = {
1003
1104
  index: "index.html",
1004
1105
  cacheControl: "public, max-age=0",
1005
1106
  dotFiles: "ignore"
1006
1107
  };
1007
1108
  async function X(e, t, n = {}) {
1008
- let r = se(t), i = {
1009
- ...Y,
1109
+ let r = ue(t), i = {
1110
+ ...ae,
1010
1111
  ...n
1011
- }, a = await ie(e), o = ae(r, i.dotFiles);
1112
+ }, a = await oe(e), o = se(r, i.dotFiles);
1012
1113
  if (o instanceof Response) return o;
1013
1114
  let s = v(a, o.length > 0 ? o.join(y) : "");
1014
1115
  if (!Q(a, s)) return new Response("Forbidden", { status: 403 });
1015
- let c = await oe(s, a, i.index);
1116
+ let c = await ce(s, a, i.index);
1016
1117
  if (c instanceof Response) return c;
1017
1118
  let l = await m(c), u = new Headers({
1018
1119
  "content-length": String(l.size),
1019
- "content-type": $(c),
1120
+ "content-type": le(c),
1020
1121
  "cache-control": i.cacheControl,
1021
1122
  "last-modified": l.mtime.toUTCString(),
1022
1123
  "x-content-type-options": "nosniff"
@@ -1032,10 +1133,10 @@ async function X(e, t, n = {}) {
1032
1133
  headers: u
1033
1134
  });
1034
1135
  }
1035
- async function ie(e) {
1136
+ async function oe(e) {
1036
1137
  return p(e);
1037
1138
  }
1038
- function ae(e, t) {
1139
+ function se(e, t) {
1039
1140
  if (e.includes("\0")) return new Response("Bad Request", { status: 400 });
1040
1141
  let n = e.replace(/\\/g, "/").split("/").filter(Boolean), r = [];
1041
1142
  for (let e of n) {
@@ -1056,7 +1157,7 @@ function ae(e, t) {
1056
1157
  }
1057
1158
  return r;
1058
1159
  }
1059
- async function oe(e, t, n) {
1160
+ async function ce(e, t, n) {
1060
1161
  try {
1061
1162
  return (await f(e)).isDirectory() ? Z(v(e, n), t) : Z(e, t);
1062
1163
  } catch {
@@ -1075,13 +1176,13 @@ function Q(e, t) {
1075
1176
  let n = _(e, t);
1076
1177
  return n === "" || !n.startsWith("..") && !g(n);
1077
1178
  }
1078
- function $(e) {
1079
- return J[h(e).toLowerCase()] ?? "application/octet-stream";
1179
+ function le(e) {
1180
+ return Y[h(e).toLowerCase()] ?? "application/octet-stream";
1080
1181
  }
1081
- function se(e) {
1182
+ function ue(e) {
1082
1183
  return typeof e.params.path == "string" ? e.params.path : e.url.pathname.replace(/^\/+/, "");
1083
1184
  }
1084
- var ce = (e, t = {}) => (n) => X(e, n, t), le = (e, ...t) => async (n) => {
1185
+ var de = (e, t = {}) => (n) => X(e, n, t), fe = (e, ...t) => async (n) => {
1085
1186
  let r = {};
1086
1187
  for (let e of t) {
1087
1188
  let t = await e(n);
@@ -1092,7 +1193,7 @@ var ce = (e, t = {}) => (n) => X(e, n, t), le = (e, ...t) => async (n) => {
1092
1193
  };
1093
1194
  //#endregion
1094
1195
  //#region src/helpers/sse.ts
1095
- function ue(e, t = {}) {
1196
+ function pe(e, t = {}) {
1096
1197
  let n = [];
1097
1198
  if (t.comment) {
1098
1199
  let e = t.comment.replace(/\r\n/g, " ").replace(/\r/g, " ").replace(/\n/g, " ");
@@ -1104,7 +1205,7 @@ function ue(e, t = {}) {
1104
1205
  }
1105
1206
  return `${n.join("\n")}\n\n`;
1106
1207
  }
1107
- var de = (e, t = {}) => (n) => {
1208
+ var $ = (e, t = {}) => (n) => {
1108
1209
  let r = new TextEncoder(), i = null, a = !1, o, s = async () => {
1109
1210
  if (!a) {
1110
1211
  a = !0;
@@ -1120,7 +1221,7 @@ var de = (e, t = {}) => (n) => {
1120
1221
  async start(t) {
1121
1222
  i = t;
1122
1223
  let c = (e, n = {}) => {
1123
- a || t.enqueue(r.encode(ue(e, n)));
1224
+ a || t.enqueue(r.encode(pe(e, n)));
1124
1225
  };
1125
1226
  n.request.signal.addEventListener("abort", () => {
1126
1227
  s();
@@ -1148,7 +1249,7 @@ var de = (e, t = {}) => (n) => {
1148
1249
  ...t.headers
1149
1250
  }
1150
1251
  });
1151
- }, fe = async (e, t) => {
1252
+ }, me = async (e, t) => {
1152
1253
  let n = JSON.stringify(await e);
1153
1254
  return new Response(n, {
1154
1255
  ...t,
@@ -1159,19 +1260,19 @@ var de = (e, t = {}) => (n) => {
1159
1260
  }
1160
1261
  });
1161
1262
  };
1162
- function pe(e, t) {
1263
+ function he(e, t) {
1163
1264
  throw new Response(null, {
1164
1265
  status: e,
1165
1266
  headers: { location: t.toString() }
1166
1267
  });
1167
1268
  }
1168
- function me(e, t) {
1269
+ function ge(e, t) {
1169
1270
  throw new Response(JSON.stringify(typeof t == "string" ? { message: t } : t), {
1170
1271
  status: e,
1171
1272
  headers: { "content-type": "application/json" }
1172
1273
  });
1173
1274
  }
1174
- var he = async (e, t) => {
1275
+ var _e = async (e, t) => {
1175
1276
  let n = await e;
1176
1277
  return new Response(n, {
1177
1278
  ...t,
@@ -1181,7 +1282,7 @@ var he = async (e, t) => {
1181
1282
  ...t?.headers
1182
1283
  }
1183
1284
  });
1184
- }, ge = async (e, t) => {
1285
+ }, ve = async (e, t) => {
1185
1286
  let n = await e;
1186
1287
  return new Response(n, {
1187
1288
  ...t,
@@ -1193,6 +1294,6 @@ var he = async (e, t) => {
1193
1294
  });
1194
1295
  };
1195
1296
  //#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 };
1297
+ 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
1298
 
1198
1299
  //# sourceMappingURL=index.es.js.map