@continuous-excellence/ze-great-dashboard-aws 0.31.12 → 0.31.14
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/lambda.mjs +862 -1229
- package/package.json +1 -1
package/dist/lambda.mjs
CHANGED
|
@@ -26114,7 +26114,7 @@ var require_dist_cjs16 = __commonJS({
|
|
|
26114
26114
|
Region: { type: "builtInParams", name: "region" },
|
|
26115
26115
|
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
|
|
26116
26116
|
};
|
|
26117
|
-
var version2 = "3.
|
|
26117
|
+
var version2 = "3.1141.0";
|
|
26118
26118
|
var packageInfo = {
|
|
26119
26119
|
version: version2
|
|
26120
26120
|
};
|
|
@@ -27892,7 +27892,7 @@ var require_dist_cjs17 = __commonJS({
|
|
|
27892
27892
|
Region: { type: "builtInParams", name: "region" },
|
|
27893
27893
|
UseDualStack: { type: "builtInParams", name: "useDualstackEndpoint" }
|
|
27894
27894
|
};
|
|
27895
|
-
var version2 = "3.
|
|
27895
|
+
var version2 = "3.1141.0";
|
|
27896
27896
|
var packageInfo = {
|
|
27897
27897
|
version: version2
|
|
27898
27898
|
};
|
|
@@ -30285,6 +30285,7 @@ var require_dist_cjs17 = __commonJS({
|
|
|
30285
30285
|
var _DKVF = "DocumentKeyValuesFilter";
|
|
30286
30286
|
var _DKVFL = "DocumentKeyValuesFilterList";
|
|
30287
30287
|
var _DLE = "DocumentLimitExceeded";
|
|
30288
|
+
var _DM = "DeletionMode";
|
|
30288
30289
|
var _DMI = "DeregisterManagedInstance";
|
|
30289
30290
|
var _DMIR = "DeregisterManagedInstanceRequest";
|
|
30290
30291
|
var _DMIRe = "DeregisterManagedInstanceResult";
|
|
@@ -30886,7 +30887,7 @@ var require_dist_cjs17 = __commonJS({
|
|
|
30886
30887
|
var _Na = "Names";
|
|
30887
30888
|
var _No = "Notifications";
|
|
30888
30889
|
var _Nod = "Nodes";
|
|
30889
|
-
var
|
|
30890
|
+
var _Node = "Node";
|
|
30890
30891
|
var _O = "Overview";
|
|
30891
30892
|
var _OA = "OpsAggregator";
|
|
30892
30893
|
var _OAL = "OpsAggregatorList";
|
|
@@ -33513,8 +33514,8 @@ var require_dist_cjs17 = __commonJS({
|
|
|
33513
33514
|
n05,
|
|
33514
33515
|
_DRPR,
|
|
33515
33516
|
0,
|
|
33516
|
-
[_RAe, _PI2, _PH],
|
|
33517
|
-
[0, 0, 0],
|
|
33517
|
+
[_RAe, _PI2, _PH, _DM],
|
|
33518
|
+
[0, 0, 0, 0],
|
|
33518
33519
|
3
|
|
33519
33520
|
];
|
|
33520
33521
|
var DeleteResourcePolicyResponse$ = [
|
|
@@ -35457,7 +35458,7 @@ var require_dist_cjs17 = __commonJS({
|
|
|
35457
35458
|
var Node$ = [
|
|
35458
35459
|
3,
|
|
35459
35460
|
n05,
|
|
35460
|
-
|
|
35461
|
+
_Node,
|
|
35461
35462
|
0,
|
|
35462
35463
|
[_CTa, _I, _Ow, _Reg, _NTo],
|
|
35463
35464
|
[4, 0, () => NodeOwnerInfo$, 0, [() => NodeType$, 0]]
|
|
@@ -40077,6 +40078,10 @@ var require_dist_cjs17 = __commonJS({
|
|
|
40077
40078
|
DELETE_SCHEMA: "DeleteSchema",
|
|
40078
40079
|
DISABLE_SCHEMA: "DisableSchema"
|
|
40079
40080
|
};
|
|
40081
|
+
var DeletionMode = {
|
|
40082
|
+
RemoveSharing: "RemoveSharing",
|
|
40083
|
+
RollbackMigration: "RollbackMigration"
|
|
40084
|
+
};
|
|
40080
40085
|
var DescribeActivationsFilterKeys = {
|
|
40081
40086
|
ACTIVATION_IDS: "ActivationIds",
|
|
40082
40087
|
DEFAULT_INSTANCE_NAME: "DefaultInstanceName",
|
|
@@ -40828,6 +40833,7 @@ var require_dist_cjs17 = __commonJS({
|
|
|
40828
40833
|
exports.DeleteResourcePolicyCommand = DeleteResourcePolicyCommand;
|
|
40829
40834
|
exports.DeleteResourcePolicyRequest$ = DeleteResourcePolicyRequest$;
|
|
40830
40835
|
exports.DeleteResourcePolicyResponse$ = DeleteResourcePolicyResponse$;
|
|
40836
|
+
exports.DeletionMode = DeletionMode;
|
|
40831
40837
|
exports.DeregisterManagedInstance$ = DeregisterManagedInstance$;
|
|
40832
40838
|
exports.DeregisterManagedInstanceCommand = DeregisterManagedInstanceCommand;
|
|
40833
40839
|
exports.DeregisterManagedInstanceRequest$ = DeregisterManagedInstanceRequest$;
|
|
@@ -42430,9 +42436,9 @@ var require_Alias = __commonJS({
|
|
|
42430
42436
|
var anchors = require_anchors();
|
|
42431
42437
|
var visit2 = require_visit();
|
|
42432
42438
|
var identity = require_identity();
|
|
42433
|
-
var
|
|
42439
|
+
var Node5 = require_Node();
|
|
42434
42440
|
var toJS = require_toJS();
|
|
42435
|
-
var Alias = class extends
|
|
42441
|
+
var Alias = class extends Node5.NodeBase {
|
|
42436
42442
|
constructor(source) {
|
|
42437
42443
|
super(identity.ALIAS);
|
|
42438
42444
|
this.source = source;
|
|
@@ -42546,10 +42552,10 @@ var require_Scalar = __commonJS({
|
|
|
42546
42552
|
"node_modules/yaml/dist/nodes/Scalar.js"(exports) {
|
|
42547
42553
|
"use strict";
|
|
42548
42554
|
var identity = require_identity();
|
|
42549
|
-
var
|
|
42555
|
+
var Node5 = require_Node();
|
|
42550
42556
|
var toJS = require_toJS();
|
|
42551
42557
|
var isScalarValue = (value) => !value || typeof value !== "function" && typeof value !== "object";
|
|
42552
|
-
var Scalar = class extends
|
|
42558
|
+
var Scalar = class extends Node5.NodeBase {
|
|
42553
42559
|
constructor(value) {
|
|
42554
42560
|
super(identity.SCALAR);
|
|
42555
42561
|
this.value = value;
|
|
@@ -42652,7 +42658,7 @@ var require_Collection = __commonJS({
|
|
|
42652
42658
|
"use strict";
|
|
42653
42659
|
var createNode = require_createNode();
|
|
42654
42660
|
var identity = require_identity();
|
|
42655
|
-
var
|
|
42661
|
+
var Node5 = require_Node();
|
|
42656
42662
|
function collectionFromPath(schema, path, value) {
|
|
42657
42663
|
let v = value;
|
|
42658
42664
|
for (let i5 = path.length - 1; i5 >= 0; --i5) {
|
|
@@ -42676,7 +42682,7 @@ var require_Collection = __commonJS({
|
|
|
42676
42682
|
});
|
|
42677
42683
|
}
|
|
42678
42684
|
var isEmptyPath = (path) => path == null || typeof path === "object" && !!path[Symbol.iterator]().next().done;
|
|
42679
|
-
var Collection = class extends
|
|
42685
|
+
var Collection = class extends Node5.NodeBase {
|
|
42680
42686
|
constructor(type, schema) {
|
|
42681
42687
|
super(type);
|
|
42682
42688
|
Object.defineProperty(this, "schema", {
|
|
@@ -49180,9 +49186,7 @@ var require_dist = __commonJS({
|
|
|
49180
49186
|
var encodeBase64 = (buf2) => {
|
|
49181
49187
|
let binary = "";
|
|
49182
49188
|
const bytes = new Uint8Array(buf2);
|
|
49183
|
-
for (let i5 = 0, len = bytes.length; i5 < len; i5++)
|
|
49184
|
-
binary += String.fromCharCode(bytes[i5]);
|
|
49185
|
-
}
|
|
49189
|
+
for (let i5 = 0, len = bytes.length; i5 < len; i5++) binary += String.fromCharCode(bytes[i5]);
|
|
49186
49190
|
return btoa(binary);
|
|
49187
49191
|
};
|
|
49188
49192
|
var decodeBase64 = (str) => {
|
|
@@ -49198,10 +49202,7 @@ var decodeBase64 = (str) => {
|
|
|
49198
49202
|
|
|
49199
49203
|
// node_modules/hono/dist/adapter/aws-lambda/handler.js
|
|
49200
49204
|
function sanitizeHeaderValue(value) {
|
|
49201
|
-
|
|
49202
|
-
if (!hasNonAscii) {
|
|
49203
|
-
return value;
|
|
49204
|
-
}
|
|
49205
|
+
if (!/[^\x00-\x7F]/.test(value)) return value;
|
|
49205
49206
|
return encodeURIComponent(value);
|
|
49206
49207
|
}
|
|
49207
49208
|
var getRequestContext = (event) => {
|
|
@@ -49229,32 +49230,23 @@ var handle = (app, { isContentTypeBinary } = { isContentTypeBinary: void 0 }) =>
|
|
|
49229
49230
|
};
|
|
49230
49231
|
var EventProcessor = class {
|
|
49231
49232
|
getHeaderValue(headers, key) {
|
|
49232
|
-
|
|
49233
|
-
return value;
|
|
49233
|
+
return headers ? Array.isArray(headers[key]) ? headers[key][0] : headers[key] : void 0;
|
|
49234
49234
|
}
|
|
49235
49235
|
getDomainName(event) {
|
|
49236
|
-
if (event.requestContext && "domainName" in event.requestContext)
|
|
49237
|
-
return event.requestContext.domainName;
|
|
49238
|
-
}
|
|
49236
|
+
if (event.requestContext && "domainName" in event.requestContext) return event.requestContext.domainName;
|
|
49239
49237
|
const hostFromHeaders = this.getHeaderValue(event.headers, "host");
|
|
49240
|
-
if (hostFromHeaders)
|
|
49241
|
-
return hostFromHeaders;
|
|
49242
|
-
}
|
|
49238
|
+
if (hostFromHeaders) return hostFromHeaders;
|
|
49243
49239
|
const multiValueHeaders = "multiValueHeaders" in event ? event.multiValueHeaders : {};
|
|
49244
|
-
|
|
49245
|
-
return hostFromMultiValueHeaders;
|
|
49240
|
+
return this.getHeaderValue(multiValueHeaders, "host");
|
|
49246
49241
|
}
|
|
49247
49242
|
createRequest(event) {
|
|
49248
49243
|
const queryString = this.getQueryString(event);
|
|
49249
|
-
const
|
|
49250
|
-
const path = this.getPath(event);
|
|
49251
|
-
const urlPath = `https://${domainName}${path}`;
|
|
49244
|
+
const urlPath = `https://${this.getDomainName(event)}${this.getPath(event)}`;
|
|
49252
49245
|
const url2 = queryString ? `${urlPath}?${queryString}` : urlPath;
|
|
49253
49246
|
const headers = this.getHeaders(event);
|
|
49254
|
-
const method = this.getMethod(event);
|
|
49255
49247
|
const requestInit = {
|
|
49256
49248
|
headers,
|
|
49257
|
-
method
|
|
49249
|
+
method: this.getMethod(event)
|
|
49258
49250
|
};
|
|
49259
49251
|
if (event.body) {
|
|
49260
49252
|
const body = event.isBase64Encoded ? decodeBase64(event.body) : new TextEncoder().encode(event.body);
|
|
@@ -49271,27 +49263,19 @@ var EventProcessor = class {
|
|
|
49271
49263
|
const contentEncoding = res.headers.get("content-encoding");
|
|
49272
49264
|
isBase64Encoded = isContentEncodingBinary(contentEncoding);
|
|
49273
49265
|
}
|
|
49274
|
-
const body = isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text();
|
|
49275
49266
|
const result = {
|
|
49276
|
-
body,
|
|
49267
|
+
body: isBase64Encoded ? encodeBase64(await res.arrayBuffer()) : await res.text(),
|
|
49277
49268
|
statusCode: res.status,
|
|
49278
49269
|
isBase64Encoded,
|
|
49279
|
-
..."multiValueHeaders" in event && event.multiValueHeaders ? {
|
|
49280
|
-
multiValueHeaders: {}
|
|
49281
|
-
} : {
|
|
49282
|
-
headers: {}
|
|
49283
|
-
}
|
|
49270
|
+
..."multiValueHeaders" in event && event.multiValueHeaders ? { multiValueHeaders: {} } : { headers: {} }
|
|
49284
49271
|
};
|
|
49285
49272
|
this.setCookies(event, res, result);
|
|
49286
|
-
if (result.multiValueHeaders) {
|
|
49287
|
-
|
|
49288
|
-
|
|
49289
|
-
|
|
49290
|
-
|
|
49291
|
-
|
|
49292
|
-
result.headers[key] = value;
|
|
49293
|
-
});
|
|
49294
|
-
}
|
|
49273
|
+
if (result.multiValueHeaders) res.headers.forEach((value, key) => {
|
|
49274
|
+
result.multiValueHeaders[key] = [value];
|
|
49275
|
+
});
|
|
49276
|
+
else res.headers.forEach((value, key) => {
|
|
49277
|
+
result.headers[key] = value;
|
|
49278
|
+
});
|
|
49295
49279
|
return result;
|
|
49296
49280
|
}
|
|
49297
49281
|
setCookies(_event, res, result) {
|
|
@@ -49315,9 +49299,7 @@ var EventV2Processor = class extends EventProcessor {
|
|
|
49315
49299
|
return event.rawQueryString;
|
|
49316
49300
|
}
|
|
49317
49301
|
getCookies(event, headers) {
|
|
49318
|
-
if (Array.isArray(event.cookies))
|
|
49319
|
-
headers.set("Cookie", event.cookies.join("; "));
|
|
49320
|
-
}
|
|
49302
|
+
if (Array.isArray(event.cookies)) headers.set("Cookie", event.cookies.join("; "));
|
|
49321
49303
|
}
|
|
49322
49304
|
setCookiesToResult(result, cookies) {
|
|
49323
49305
|
result.cookies = cookies;
|
|
@@ -49326,11 +49308,7 @@ var EventV2Processor = class extends EventProcessor {
|
|
|
49326
49308
|
const headers = new Headers();
|
|
49327
49309
|
this.getCookies(event, headers);
|
|
49328
49310
|
if (event.headers) {
|
|
49329
|
-
for (const [k5, v] of Object.entries(event.headers))
|
|
49330
|
-
if (v) {
|
|
49331
|
-
headers.set(k5, v);
|
|
49332
|
-
}
|
|
49333
|
-
}
|
|
49311
|
+
for (const [k5, v] of Object.entries(event.headers)) if (v) headers.set(k5, v);
|
|
49334
49312
|
}
|
|
49335
49313
|
return headers;
|
|
49336
49314
|
}
|
|
@@ -49344,13 +49322,8 @@ var EventV1Processor = class extends EventProcessor {
|
|
|
49344
49322
|
return event.httpMethod;
|
|
49345
49323
|
}
|
|
49346
49324
|
getQueryString(event) {
|
|
49347
|
-
if (event.multiValueQueryStringParameters) {
|
|
49348
|
-
|
|
49349
|
-
([key, values]) => values.map((value) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&")
|
|
49350
|
-
).join("&");
|
|
49351
|
-
} else {
|
|
49352
|
-
return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value || "")}`).join("&");
|
|
49353
|
-
}
|
|
49325
|
+
if (event.multiValueQueryStringParameters) return Object.entries(event.multiValueQueryStringParameters || {}).filter(([, value]) => value).map(([key, values]) => values.map((value) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`).join("&")).join("&");
|
|
49326
|
+
else return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value !== void 0).map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value || "")}`).join("&");
|
|
49354
49327
|
}
|
|
49355
49328
|
getCookies(_event, _headers) {
|
|
49356
49329
|
}
|
|
@@ -49358,25 +49331,15 @@ var EventV1Processor = class extends EventProcessor {
|
|
|
49358
49331
|
const headers = new Headers();
|
|
49359
49332
|
this.getCookies(event, headers);
|
|
49360
49333
|
if (event.multiValueHeaders) {
|
|
49361
|
-
for (const [k5, values] of Object.entries(event.multiValueHeaders))
|
|
49362
|
-
if (values) {
|
|
49363
|
-
values.forEach((v) => headers.append(k5, sanitizeHeaderValue(v)));
|
|
49364
|
-
}
|
|
49365
|
-
}
|
|
49334
|
+
for (const [k5, values] of Object.entries(event.multiValueHeaders)) if (values) values.forEach((v) => headers.append(k5, sanitizeHeaderValue(v)));
|
|
49366
49335
|
}
|
|
49367
49336
|
if (event.headers) {
|
|
49368
|
-
for (const [k5, v] of Object.entries(event.headers))
|
|
49369
|
-
if (v && !headers.has(k5)) {
|
|
49370
|
-
headers.set(k5, sanitizeHeaderValue(v));
|
|
49371
|
-
}
|
|
49372
|
-
}
|
|
49337
|
+
for (const [k5, v] of Object.entries(event.headers)) if (v && !headers.has(k5)) headers.set(k5, sanitizeHeaderValue(v));
|
|
49373
49338
|
}
|
|
49374
49339
|
return headers;
|
|
49375
49340
|
}
|
|
49376
49341
|
setCookiesToResult(result, cookies) {
|
|
49377
|
-
result.multiValueHeaders = {
|
|
49378
|
-
"set-cookie": cookies
|
|
49379
|
-
};
|
|
49342
|
+
result.multiValueHeaders = { "set-cookie": cookies };
|
|
49380
49343
|
}
|
|
49381
49344
|
};
|
|
49382
49345
|
var v1Processor = new EventV1Processor();
|
|
@@ -49384,19 +49347,11 @@ var ALBProcessor = class extends EventProcessor {
|
|
|
49384
49347
|
getHeaders(event) {
|
|
49385
49348
|
const headers = new Headers();
|
|
49386
49349
|
if (event.multiValueHeaders) {
|
|
49387
|
-
for (const [key, values] of Object.entries(event.multiValueHeaders)) {
|
|
49388
|
-
|
|
49389
|
-
|
|
49390
|
-
headers.set(key, sanitizedValue);
|
|
49391
|
-
}
|
|
49392
|
-
}
|
|
49393
|
-
} else {
|
|
49394
|
-
for (const [key, value] of Object.entries(event.headers ?? {})) {
|
|
49395
|
-
if (value) {
|
|
49396
|
-
headers.set(key, sanitizeHeaderValue(value));
|
|
49397
|
-
}
|
|
49350
|
+
for (const [key, values] of Object.entries(event.multiValueHeaders)) if (values && Array.isArray(values)) {
|
|
49351
|
+
const sanitizedValue = sanitizeHeaderValue(values.join("; "));
|
|
49352
|
+
headers.set(key, sanitizedValue);
|
|
49398
49353
|
}
|
|
49399
|
-
}
|
|
49354
|
+
} else for (const [key, value] of Object.entries(event.headers ?? {})) if (value) headers.set(key, sanitizeHeaderValue(value));
|
|
49400
49355
|
return headers;
|
|
49401
49356
|
}
|
|
49402
49357
|
getPath(event) {
|
|
@@ -49406,29 +49361,18 @@ var ALBProcessor = class extends EventProcessor {
|
|
|
49406
49361
|
return event.httpMethod;
|
|
49407
49362
|
}
|
|
49408
49363
|
getQueryString(event) {
|
|
49409
|
-
if (event.multiValueQueryStringParameters) {
|
|
49410
|
-
|
|
49411
|
-
} else {
|
|
49412
|
-
return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${value}`).join("&");
|
|
49413
|
-
}
|
|
49364
|
+
if (event.multiValueQueryStringParameters) return Object.entries(event.multiValueQueryStringParameters || {}).filter(([, value]) => value).map(([key, value]) => `${key}=${value.join(`&${key}=`)}`).join("&");
|
|
49365
|
+
else return Object.entries(event.queryStringParameters || {}).filter(([, value]) => value !== void 0).map(([key, value]) => `${key}=${value}`).join("&");
|
|
49414
49366
|
}
|
|
49415
49367
|
getCookies(event, headers) {
|
|
49416
49368
|
let cookie;
|
|
49417
|
-
if (event.multiValueHeaders)
|
|
49418
|
-
|
|
49419
|
-
|
|
49420
|
-
cookie = event.headers ? event.headers["cookie"] : void 0;
|
|
49421
|
-
}
|
|
49422
|
-
if (cookie) {
|
|
49423
|
-
headers.append("Cookie", cookie);
|
|
49424
|
-
}
|
|
49369
|
+
if (event.multiValueHeaders) cookie = event.multiValueHeaders["cookie"]?.join("; ");
|
|
49370
|
+
else cookie = event.headers ? event.headers["cookie"] : void 0;
|
|
49371
|
+
if (cookie) headers.append("Cookie", cookie);
|
|
49425
49372
|
}
|
|
49426
49373
|
setCookiesToResult(result, cookies) {
|
|
49427
|
-
if (result.multiValueHeaders)
|
|
49428
|
-
|
|
49429
|
-
} else {
|
|
49430
|
-
result.headers["set-cookie"] = cookies[0];
|
|
49431
|
-
}
|
|
49374
|
+
if (result.multiValueHeaders) result.multiValueHeaders["set-cookie"] = cookies;
|
|
49375
|
+
else result.headers["set-cookie"] = cookies[0];
|
|
49432
49376
|
}
|
|
49433
49377
|
};
|
|
49434
49378
|
var albProcessor = new ALBProcessor();
|
|
@@ -49445,11 +49389,7 @@ var LatticeV2Processor = class extends EventProcessor {
|
|
|
49445
49389
|
getHeaders(event) {
|
|
49446
49390
|
const headers = new Headers();
|
|
49447
49391
|
if (event.headers) {
|
|
49448
|
-
for (const [k5, values] of Object.entries(event.headers))
|
|
49449
|
-
if (values) {
|
|
49450
|
-
values.forEach((v) => headers.append(k5, sanitizeHeaderValue(v)));
|
|
49451
|
-
}
|
|
49452
|
-
}
|
|
49392
|
+
for (const [k5, values] of Object.entries(event.headers)) if (values) values.forEach((v) => headers.append(k5, sanitizeHeaderValue(v)));
|
|
49453
49393
|
}
|
|
49454
49394
|
return headers;
|
|
49455
49395
|
}
|
|
@@ -49464,39 +49404,25 @@ var LatticeV2Processor = class extends EventProcessor {
|
|
|
49464
49404
|
};
|
|
49465
49405
|
var latticeV2Processor = new LatticeV2Processor();
|
|
49466
49406
|
var getProcessor = (event) => {
|
|
49467
|
-
if (isProxyEventALB(event))
|
|
49468
|
-
|
|
49469
|
-
|
|
49470
|
-
if (isProxyEventV2(event)) {
|
|
49471
|
-
return v2Processor;
|
|
49472
|
-
}
|
|
49473
|
-
if (isLatticeEventV2(event)) {
|
|
49474
|
-
return latticeV2Processor;
|
|
49475
|
-
}
|
|
49407
|
+
if (isProxyEventALB(event)) return albProcessor;
|
|
49408
|
+
if (isProxyEventV2(event)) return v2Processor;
|
|
49409
|
+
if (isLatticeEventV2(event)) return latticeV2Processor;
|
|
49476
49410
|
return v1Processor;
|
|
49477
49411
|
};
|
|
49478
49412
|
var isProxyEventALB = (event) => {
|
|
49479
|
-
if (event.requestContext)
|
|
49480
|
-
return Object.hasOwn(event.requestContext, "elb");
|
|
49481
|
-
}
|
|
49413
|
+
if (event.requestContext) return Object.hasOwn(event.requestContext, "elb");
|
|
49482
49414
|
return false;
|
|
49483
49415
|
};
|
|
49484
49416
|
var isProxyEventV2 = (event) => {
|
|
49485
49417
|
return Object.hasOwn(event, "rawPath") && Object.hasOwn(event.requestContext ?? {}, "http");
|
|
49486
49418
|
};
|
|
49487
49419
|
var isLatticeEventV2 = (event) => {
|
|
49488
|
-
if (event.requestContext)
|
|
49489
|
-
return Object.hasOwn(event.requestContext, "serviceArn");
|
|
49490
|
-
}
|
|
49420
|
+
if (event.requestContext) return Object.hasOwn(event.requestContext, "serviceArn");
|
|
49491
49421
|
return false;
|
|
49492
49422
|
};
|
|
49493
49423
|
var defaultIsContentTypeBinary = (contentType) => {
|
|
49494
|
-
if (/^application\/vnd\.(?:apple\.installer|mozilla\.xul)\+xml\s*(?:;|$)/i.test(contentType))
|
|
49495
|
-
|
|
49496
|
-
}
|
|
49497
|
-
return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/i.test(
|
|
49498
|
-
contentType
|
|
49499
|
-
);
|
|
49424
|
+
if (/^application\/vnd\.(?:apple\.installer|mozilla\.xul)\+xml\s*(?:;|$)/i.test(contentType)) return true;
|
|
49425
|
+
return !/^text\/(?:plain|html|css|javascript|csv)|(?:\/|\+)(?:json|xml)\s*(?:;|$)/i.test(contentType);
|
|
49500
49426
|
};
|
|
49501
49427
|
var isContentEncodingBinary = (contentEncoding) => {
|
|
49502
49428
|
return !!contentEncoding && !/^identity$/i.test(contentEncoding);
|
|
@@ -71085,152 +71011,68 @@ function unsupportedPanelOperation(boardName, panel, source, error63) {
|
|
|
71085
71011
|
);
|
|
71086
71012
|
}
|
|
71087
71013
|
|
|
71088
|
-
// node_modules/hono/dist/compose.js
|
|
71089
|
-
var compose = (middleware, onError, onNotFound) => {
|
|
71090
|
-
return (context, next) => {
|
|
71091
|
-
let index = -1;
|
|
71092
|
-
return dispatch(0);
|
|
71093
|
-
async function dispatch(i5) {
|
|
71094
|
-
if (i5 <= index) {
|
|
71095
|
-
throw new Error("next() called multiple times");
|
|
71096
|
-
}
|
|
71097
|
-
index = i5;
|
|
71098
|
-
let res;
|
|
71099
|
-
let isError = false;
|
|
71100
|
-
let handler2;
|
|
71101
|
-
if (middleware[i5]) {
|
|
71102
|
-
handler2 = middleware[i5][0][0];
|
|
71103
|
-
context.req.routeIndex = i5;
|
|
71104
|
-
} else {
|
|
71105
|
-
handler2 = i5 === middleware.length && next || void 0;
|
|
71106
|
-
}
|
|
71107
|
-
if (handler2) {
|
|
71108
|
-
try {
|
|
71109
|
-
res = await handler2(context, () => dispatch(i5 + 1));
|
|
71110
|
-
} catch (err) {
|
|
71111
|
-
if (err instanceof Error && onError) {
|
|
71112
|
-
context.error = err;
|
|
71113
|
-
res = await onError(err, context);
|
|
71114
|
-
isError = true;
|
|
71115
|
-
} else {
|
|
71116
|
-
throw err;
|
|
71117
|
-
}
|
|
71118
|
-
}
|
|
71119
|
-
} else {
|
|
71120
|
-
if (context.finalized === false && onNotFound) {
|
|
71121
|
-
res = await onNotFound(context);
|
|
71122
|
-
}
|
|
71123
|
-
}
|
|
71124
|
-
if (res && (context.finalized === false || isError)) {
|
|
71125
|
-
context.res = res;
|
|
71126
|
-
}
|
|
71127
|
-
return context;
|
|
71128
|
-
}
|
|
71129
|
-
};
|
|
71130
|
-
};
|
|
71131
|
-
|
|
71132
71014
|
// node_modules/hono/dist/request/constants.js
|
|
71133
71015
|
var GET_MATCH_RESULT = /* @__PURE__ */ Symbol();
|
|
71134
71016
|
|
|
71135
71017
|
// node_modules/hono/dist/utils/buffer.js
|
|
71136
71018
|
var bufferToFormData = (arrayBuffer, contentType) => {
|
|
71137
|
-
|
|
71138
|
-
headers: {
|
|
71139
|
-
// Normalize the media type (case-insensitive) while keeping parameters like the boundary
|
|
71140
|
-
"Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase())
|
|
71141
|
-
}
|
|
71142
|
-
});
|
|
71143
|
-
return response.formData();
|
|
71019
|
+
return new Response(arrayBuffer, { headers: { "Content-Type": contentType.replace(/^[^;]+/, (mediaType) => mediaType.toLowerCase()) } }).formData();
|
|
71144
71020
|
};
|
|
71145
71021
|
|
|
71146
71022
|
// node_modules/hono/dist/utils/body.js
|
|
71147
|
-
var MAX_NESTING_DEPTH = 32;
|
|
71148
71023
|
var MAX_NESTED_OBJECTS = 1e4;
|
|
71149
71024
|
var isRawRequest = (request) => "headers" in request;
|
|
71150
71025
|
var parseBody = async (request, options = /* @__PURE__ */ Object.create(null)) => {
|
|
71151
71026
|
const { all = false, dot = false } = options;
|
|
71152
|
-
const
|
|
71153
|
-
|
|
71154
|
-
|
|
71155
|
-
|
|
71156
|
-
|
|
71157
|
-
}
|
|
71027
|
+
const mediaType = (isRawRequest(request) ? request.headers : request.raw.headers).get("Content-Type")?.split(";")[0].trim().toLowerCase();
|
|
71028
|
+
if (mediaType === "multipart/form-data" || mediaType === "application/x-www-form-urlencoded") return parseFormData(request, {
|
|
71029
|
+
all,
|
|
71030
|
+
dot
|
|
71031
|
+
});
|
|
71158
71032
|
return {};
|
|
71159
71033
|
};
|
|
71160
71034
|
async function parseFormData(request, options) {
|
|
71161
|
-
if (!isRawRequest(request) && request.bodyCache.formData)
|
|
71162
|
-
return convertFormDataToBodyData(
|
|
71163
|
-
await request.bodyCache.formData,
|
|
71164
|
-
options
|
|
71165
|
-
);
|
|
71166
|
-
}
|
|
71035
|
+
if (!isRawRequest(request) && request.bodyCache.formData) return convertFormDataToBodyData(await request.bodyCache.formData, options);
|
|
71167
71036
|
const headers = isRawRequest(request) ? request.headers : request.raw.headers;
|
|
71168
71037
|
const arrayBuffer = await request.arrayBuffer();
|
|
71169
71038
|
const formDataPromise = bufferToFormData(arrayBuffer, headers.get("Content-Type") || "");
|
|
71170
|
-
if (!isRawRequest(request))
|
|
71171
|
-
request.bodyCache.formData = formDataPromise;
|
|
71172
|
-
}
|
|
71039
|
+
if (!isRawRequest(request)) request.bodyCache.formData = formDataPromise;
|
|
71173
71040
|
const formData = await formDataPromise;
|
|
71174
|
-
if (formData)
|
|
71175
|
-
return convertFormDataToBodyData(formData, options);
|
|
71176
|
-
}
|
|
71041
|
+
if (formData) return convertFormDataToBodyData(formData, options);
|
|
71177
71042
|
return {};
|
|
71178
71043
|
}
|
|
71179
71044
|
function convertFormDataToBodyData(formData, options) {
|
|
71180
71045
|
const form = /* @__PURE__ */ Object.create(null);
|
|
71181
71046
|
const nestingState = { count: 0 };
|
|
71182
71047
|
formData.forEach((value, key) => {
|
|
71183
|
-
|
|
71184
|
-
|
|
71185
|
-
|
|
71186
|
-
|
|
71187
|
-
|
|
71048
|
+
if (!(options.all || key.endsWith("[]"))) form[key] = value;
|
|
71049
|
+
else handleParsingAllValues(form, key, value);
|
|
71050
|
+
});
|
|
71051
|
+
if (options.dot) Object.entries(form).forEach(([key, value]) => {
|
|
71052
|
+
if (key.includes(".")) {
|
|
71053
|
+
handleParsingNestedValues(form, key, value, nestingState);
|
|
71054
|
+
delete form[key];
|
|
71188
71055
|
}
|
|
71189
71056
|
});
|
|
71190
|
-
if (options.dot) {
|
|
71191
|
-
Object.entries(form).forEach(([key, value]) => {
|
|
71192
|
-
const shouldParseDotValues = key.includes(".");
|
|
71193
|
-
if (shouldParseDotValues) {
|
|
71194
|
-
handleParsingNestedValues(form, key, value, nestingState);
|
|
71195
|
-
delete form[key];
|
|
71196
|
-
}
|
|
71197
|
-
});
|
|
71198
|
-
}
|
|
71199
71057
|
return form;
|
|
71200
71058
|
}
|
|
71201
71059
|
var handleParsingAllValues = (form, key, value) => {
|
|
71202
71060
|
if (form[key] !== void 0) {
|
|
71203
|
-
if (Array.isArray(form[key]))
|
|
71204
|
-
|
|
71205
|
-
|
|
71206
|
-
|
|
71207
|
-
form[key] = [form[key], value];
|
|
71208
|
-
}
|
|
71209
|
-
} else {
|
|
71210
|
-
if (!key.endsWith("[]")) {
|
|
71211
|
-
form[key] = value;
|
|
71212
|
-
} else {
|
|
71213
|
-
form[key] = [value];
|
|
71214
|
-
}
|
|
71215
|
-
}
|
|
71061
|
+
if (Array.isArray(form[key])) form[key].push(value);
|
|
71062
|
+
else form[key] = [form[key], value];
|
|
71063
|
+
} else if (!key.endsWith("[]")) form[key] = value;
|
|
71064
|
+
else form[key] = [value];
|
|
71216
71065
|
};
|
|
71217
71066
|
var handleParsingNestedValues = (form, key, value, state2) => {
|
|
71218
|
-
if (/(?:^|\.)__proto__\./.test(key))
|
|
71219
|
-
return;
|
|
71220
|
-
}
|
|
71067
|
+
if (/(?:^|\.)__proto__\./.test(key)) return;
|
|
71221
71068
|
let nestedForm = form;
|
|
71222
|
-
const keys = key.split(".",
|
|
71223
|
-
if (keys.length >
|
|
71224
|
-
throwNestingLimitExceeded();
|
|
71225
|
-
}
|
|
71069
|
+
const keys = key.split(".", 34);
|
|
71070
|
+
if (keys.length > 33) throwNestingLimitExceeded();
|
|
71226
71071
|
keys.forEach((key2, index) => {
|
|
71227
|
-
if (index === keys.length - 1)
|
|
71228
|
-
|
|
71229
|
-
} else {
|
|
71072
|
+
if (index === keys.length - 1) nestedForm[key2] = value;
|
|
71073
|
+
else {
|
|
71230
71074
|
if (!nestedForm[key2] || typeof nestedForm[key2] !== "object" || Array.isArray(nestedForm[key2]) || nestedForm[key2] instanceof File) {
|
|
71231
|
-
if (state2.count++ >= MAX_NESTED_OBJECTS)
|
|
71232
|
-
throwNestingLimitExceeded();
|
|
71233
|
-
}
|
|
71075
|
+
if (state2.count++ >= MAX_NESTED_OBJECTS) throwNestingLimitExceeded();
|
|
71234
71076
|
nestedForm[key2] = /* @__PURE__ */ Object.create(null);
|
|
71235
71077
|
}
|
|
71236
71078
|
nestedForm = nestedForm[key2];
|
|
@@ -71244,9 +71086,7 @@ var throwNestingLimitExceeded = () => {
|
|
|
71244
71086
|
// node_modules/hono/dist/utils/url.js
|
|
71245
71087
|
var splitPath = (path) => {
|
|
71246
71088
|
const paths = path.split("/");
|
|
71247
|
-
if (paths[0] === "")
|
|
71248
|
-
paths.shift();
|
|
71249
|
-
}
|
|
71089
|
+
if (paths[0] === "") paths.shift();
|
|
71250
71090
|
return paths;
|
|
71251
71091
|
};
|
|
71252
71092
|
var splitRoutingPath = (routePath) => {
|
|
@@ -71261,34 +71101,42 @@ var extractGroupsFromPath = (path) => {
|
|
|
71261
71101
|
groups.push([mark, match2]);
|
|
71262
71102
|
return mark;
|
|
71263
71103
|
});
|
|
71264
|
-
return {
|
|
71104
|
+
return {
|
|
71105
|
+
groups,
|
|
71106
|
+
path
|
|
71107
|
+
};
|
|
71265
71108
|
};
|
|
71266
71109
|
var replaceGroupMarks = (paths, groups) => {
|
|
71267
71110
|
for (let i5 = groups.length - 1; i5 >= 0; i5--) {
|
|
71268
71111
|
const [mark] = groups[i5];
|
|
71269
|
-
for (let j5 = paths.length - 1; j5 >= 0; j5--) {
|
|
71270
|
-
|
|
71271
|
-
|
|
71272
|
-
break;
|
|
71273
|
-
}
|
|
71112
|
+
for (let j5 = paths.length - 1; j5 >= 0; j5--) if (paths[j5].includes(mark)) {
|
|
71113
|
+
paths[j5] = paths[j5].replace(mark, groups[i5][1]);
|
|
71114
|
+
break;
|
|
71274
71115
|
}
|
|
71275
71116
|
}
|
|
71276
71117
|
return paths;
|
|
71277
71118
|
};
|
|
71278
71119
|
var patternCache = {};
|
|
71279
71120
|
var getPattern = (label, next) => {
|
|
71280
|
-
if (label === "*")
|
|
71281
|
-
return "*";
|
|
71282
|
-
}
|
|
71121
|
+
if (label === "*") return "*";
|
|
71283
71122
|
const match2 = label.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
71284
71123
|
if (match2) {
|
|
71285
71124
|
const cacheKey = `${label}#${next}`;
|
|
71286
71125
|
if (!patternCache[cacheKey]) {
|
|
71287
|
-
if (match2[2])
|
|
71288
|
-
|
|
71289
|
-
|
|
71290
|
-
|
|
71291
|
-
|
|
71126
|
+
if (match2[2]) patternCache[cacheKey] = next && next[0] !== ":" && next[0] !== "*" ? [
|
|
71127
|
+
cacheKey,
|
|
71128
|
+
match2[1],
|
|
71129
|
+
new RegExp(`^${match2[2]}(?=/${next})`)
|
|
71130
|
+
] : [
|
|
71131
|
+
label,
|
|
71132
|
+
match2[1],
|
|
71133
|
+
new RegExp(`^${match2[2]}$`)
|
|
71134
|
+
];
|
|
71135
|
+
else patternCache[cacheKey] = [
|
|
71136
|
+
label,
|
|
71137
|
+
match2[1],
|
|
71138
|
+
true
|
|
71139
|
+
];
|
|
71292
71140
|
}
|
|
71293
71141
|
return patternCache[cacheKey];
|
|
71294
71142
|
}
|
|
@@ -71320,9 +71168,7 @@ var getPath = (request) => {
|
|
|
71320
71168
|
const end2 = queryIndex === -1 ? hashIndex === -1 ? void 0 : hashIndex : hashIndex === -1 ? queryIndex : Math.min(queryIndex, hashIndex);
|
|
71321
71169
|
const path = url2.slice(start, end2);
|
|
71322
71170
|
return tryDecodeURI(path.includes("%25") ? path.replace(/%25/g, "%2525") : path);
|
|
71323
|
-
} else if (charCode === 63 || charCode === 35)
|
|
71324
|
-
break;
|
|
71325
|
-
}
|
|
71171
|
+
} else if (charCode === 63 || charCode === 35) break;
|
|
71326
71172
|
}
|
|
71327
71173
|
return url2.slice(start, i5);
|
|
71328
71174
|
};
|
|
@@ -71331,74 +71177,52 @@ var getPathNoStrict = (request) => {
|
|
|
71331
71177
|
return result.length > 1 && result.at(-1) === "/" ? result.slice(0, -1) : result;
|
|
71332
71178
|
};
|
|
71333
71179
|
var mergePath = (base, sub, ...rest) => {
|
|
71334
|
-
if (rest.length)
|
|
71335
|
-
sub = mergePath(sub, ...rest);
|
|
71336
|
-
}
|
|
71180
|
+
if (rest.length) sub = mergePath(sub, ...rest);
|
|
71337
71181
|
return `${base?.[0] === "/" ? "" : "/"}${base}${sub === "/" ? "" : `${base?.at(-1) === "/" ? "" : "/"}${sub?.[0] === "/" ? sub.slice(1) : sub}`}`;
|
|
71338
71182
|
};
|
|
71339
71183
|
var checkOptionalParameter = (path) => {
|
|
71340
|
-
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":"))
|
|
71341
|
-
return null;
|
|
71342
|
-
}
|
|
71184
|
+
if (path.charCodeAt(path.length - 1) !== 63 || !path.includes(":")) return null;
|
|
71343
71185
|
const segments = path.split("/");
|
|
71344
71186
|
const results = [];
|
|
71345
71187
|
let basePath = "";
|
|
71346
71188
|
segments.forEach((segment) => {
|
|
71347
|
-
if (segment !== "" && !/\:/.test(segment))
|
|
71348
|
-
|
|
71349
|
-
} else if (/\:/.test(segment)) {
|
|
71189
|
+
if (segment !== "" && !/\:/.test(segment)) basePath += "/" + segment;
|
|
71190
|
+
else if (/\:/.test(segment)) {
|
|
71350
71191
|
if (segment.charCodeAt(segment.length - 1) === 63) {
|
|
71351
|
-
if (results.length === 0 && basePath === "")
|
|
71352
|
-
|
|
71353
|
-
} else {
|
|
71354
|
-
results.push(basePath);
|
|
71355
|
-
}
|
|
71192
|
+
if (results.length === 0 && basePath === "") results.push("/");
|
|
71193
|
+
else results.push(basePath);
|
|
71356
71194
|
const optionalSegment = segment.slice(0, -1);
|
|
71357
71195
|
basePath += "/" + optionalSegment;
|
|
71358
71196
|
results.push(basePath);
|
|
71359
|
-
} else
|
|
71360
|
-
basePath += "/" + segment;
|
|
71361
|
-
}
|
|
71197
|
+
} else basePath += "/" + segment;
|
|
71362
71198
|
}
|
|
71363
71199
|
});
|
|
71364
71200
|
return results.filter((v, i5, a5) => a5.indexOf(v) === i5);
|
|
71365
71201
|
};
|
|
71366
71202
|
var tryDecodeURIComponent = (str) => str.indexOf("%") !== -1 ? tryDecode(str, decodeURIComponent_) : str;
|
|
71367
71203
|
var _decodeURI = (value) => {
|
|
71368
|
-
if (value.indexOf("+") !== -1)
|
|
71369
|
-
value = value.replace(/\+/g, " ");
|
|
71370
|
-
}
|
|
71204
|
+
if (value.indexOf("+") !== -1) value = value.replace(/\+/g, " ");
|
|
71371
71205
|
return tryDecodeURIComponent(value);
|
|
71372
71206
|
};
|
|
71373
71207
|
var _getQueryParam = (url2, key, multiple) => {
|
|
71374
71208
|
const hashIndex = url2.indexOf("#", 8);
|
|
71375
|
-
if (hashIndex !== -1)
|
|
71376
|
-
url2 = url2.slice(0, hashIndex);
|
|
71377
|
-
}
|
|
71209
|
+
if (hashIndex !== -1) url2 = url2.slice(0, hashIndex);
|
|
71378
71210
|
let encoded;
|
|
71379
71211
|
if (!multiple && key && key.indexOf("%") === -1 && key.indexOf("+") === -1) {
|
|
71380
71212
|
let keyIndex2 = url2.indexOf("?", 8);
|
|
71381
|
-
if (keyIndex2 === -1)
|
|
71382
|
-
|
|
71383
|
-
}
|
|
71384
|
-
if (!url2.startsWith(key, keyIndex2 + 1)) {
|
|
71385
|
-
keyIndex2 = url2.indexOf(`&${key}`, keyIndex2 + 1);
|
|
71386
|
-
}
|
|
71213
|
+
if (keyIndex2 === -1) return;
|
|
71214
|
+
if (!url2.startsWith(key, keyIndex2 + 1)) keyIndex2 = url2.indexOf(`&${key}`, keyIndex2 + 1);
|
|
71387
71215
|
while (keyIndex2 !== -1) {
|
|
71388
71216
|
const trailingKeyCode = url2.charCodeAt(keyIndex2 + key.length + 1);
|
|
71389
71217
|
if (trailingKeyCode === 61) {
|
|
71390
71218
|
const valueIndex = keyIndex2 + key.length + 2;
|
|
71391
71219
|
const endIndex = url2.indexOf("&", valueIndex);
|
|
71392
71220
|
return _decodeURI(url2.slice(valueIndex, endIndex === -1 ? void 0 : endIndex));
|
|
71393
|
-
} else if (trailingKeyCode == 38 || isNaN(trailingKeyCode))
|
|
71394
|
-
return "";
|
|
71395
|
-
}
|
|
71221
|
+
} else if (trailingKeyCode == 38 || isNaN(trailingKeyCode)) return "";
|
|
71396
71222
|
keyIndex2 = url2.indexOf(`&${key}`, keyIndex2 + 1);
|
|
71397
71223
|
}
|
|
71398
71224
|
encoded = /[%+]/.test(url2);
|
|
71399
|
-
if (!encoded)
|
|
71400
|
-
return void 0;
|
|
71401
|
-
}
|
|
71225
|
+
if (!encoded) return;
|
|
71402
71226
|
}
|
|
71403
71227
|
const results = /* @__PURE__ */ Object.create(null);
|
|
71404
71228
|
encoded ??= /[%+]/.test(url2);
|
|
@@ -71406,38 +71230,21 @@ var _getQueryParam = (url2, key, multiple) => {
|
|
|
71406
71230
|
while (keyIndex !== -1) {
|
|
71407
71231
|
const nextKeyIndex = url2.indexOf("&", keyIndex + 1);
|
|
71408
71232
|
let valueIndex = url2.indexOf("=", keyIndex);
|
|
71409
|
-
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1)
|
|
71410
|
-
|
|
71411
|
-
|
|
71412
|
-
let name = url2.slice(
|
|
71413
|
-
keyIndex + 1,
|
|
71414
|
-
valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex
|
|
71415
|
-
);
|
|
71416
|
-
if (encoded) {
|
|
71417
|
-
name = _decodeURI(name);
|
|
71418
|
-
}
|
|
71233
|
+
if (valueIndex > nextKeyIndex && nextKeyIndex !== -1) valueIndex = -1;
|
|
71234
|
+
let name = url2.slice(keyIndex + 1, valueIndex === -1 ? nextKeyIndex === -1 ? void 0 : nextKeyIndex : valueIndex);
|
|
71235
|
+
if (encoded) name = _decodeURI(name);
|
|
71419
71236
|
keyIndex = nextKeyIndex;
|
|
71420
|
-
if (name === "")
|
|
71421
|
-
continue;
|
|
71422
|
-
}
|
|
71237
|
+
if (name === "") continue;
|
|
71423
71238
|
let value;
|
|
71424
|
-
if (valueIndex === -1)
|
|
71425
|
-
|
|
71426
|
-
} else {
|
|
71239
|
+
if (valueIndex === -1) value = "";
|
|
71240
|
+
else {
|
|
71427
71241
|
value = url2.slice(valueIndex + 1, nextKeyIndex === -1 ? void 0 : nextKeyIndex);
|
|
71428
|
-
if (encoded)
|
|
71429
|
-
value = _decodeURI(value);
|
|
71430
|
-
}
|
|
71242
|
+
if (encoded) value = _decodeURI(value);
|
|
71431
71243
|
}
|
|
71432
71244
|
if (multiple) {
|
|
71433
|
-
if (!(results[name] && Array.isArray(results[name])))
|
|
71434
|
-
results[name] = [];
|
|
71435
|
-
}
|
|
71436
|
-
;
|
|
71245
|
+
if (!(results[name] && Array.isArray(results[name]))) results[name] = [];
|
|
71437
71246
|
results[name].push(value);
|
|
71438
|
-
} else
|
|
71439
|
-
results[name] ??= value;
|
|
71440
|
-
}
|
|
71247
|
+
} else results[name] ??= value;
|
|
71441
71248
|
}
|
|
71442
71249
|
return key ? results[key] : results;
|
|
71443
71250
|
};
|
|
@@ -71450,36 +71257,35 @@ var decodeURIComponent_ = decodeURIComponent;
|
|
|
71450
71257
|
// node_modules/hono/dist/request.js
|
|
71451
71258
|
var HonoRequest = class {
|
|
71452
71259
|
/**
|
|
71453
|
-
|
|
71454
|
-
|
|
71455
|
-
|
|
71456
|
-
|
|
71457
|
-
|
|
71458
|
-
|
|
71459
|
-
|
|
71460
|
-
|
|
71461
|
-
|
|
71462
|
-
|
|
71463
|
-
|
|
71464
|
-
|
|
71465
|
-
|
|
71260
|
+
* `.raw` can get the raw Request object.
|
|
71261
|
+
*
|
|
71262
|
+
* @see {@link https://hono.dev/docs/api/request#raw}
|
|
71263
|
+
*
|
|
71264
|
+
* @example
|
|
71265
|
+
* ```ts
|
|
71266
|
+
* // For Cloudflare Workers
|
|
71267
|
+
* app.post('/', async (c) => {
|
|
71268
|
+
* const metadata = c.req.raw.cf?.hostMetadata?
|
|
71269
|
+
* ...
|
|
71270
|
+
* })
|
|
71271
|
+
* ```
|
|
71272
|
+
*/
|
|
71466
71273
|
raw;
|
|
71467
71274
|
#validatedData;
|
|
71468
|
-
// Short name of validatedData
|
|
71469
71275
|
#matchResult;
|
|
71470
71276
|
routeIndex = 0;
|
|
71471
71277
|
/**
|
|
71472
|
-
|
|
71473
|
-
|
|
71474
|
-
|
|
71475
|
-
|
|
71476
|
-
|
|
71477
|
-
|
|
71478
|
-
|
|
71479
|
-
|
|
71480
|
-
|
|
71481
|
-
|
|
71482
|
-
|
|
71278
|
+
* `.path` can get the pathname of the request.
|
|
71279
|
+
*
|
|
71280
|
+
* @see {@link https://hono.dev/docs/api/request#path}
|
|
71281
|
+
*
|
|
71282
|
+
* @example
|
|
71283
|
+
* ```ts
|
|
71284
|
+
* app.get('/about/me', (c) => {
|
|
71285
|
+
* const pathname = c.req.path // `/about/me`
|
|
71286
|
+
* })
|
|
71287
|
+
* ```
|
|
71288
|
+
*/
|
|
71483
71289
|
path;
|
|
71484
71290
|
bodyCache = {};
|
|
71485
71291
|
constructor(request, path = "/", matchResult = [[]]) {
|
|
@@ -71500,9 +71306,7 @@ var HonoRequest = class {
|
|
|
71500
71306
|
const keys = Object.keys(this.#matchResult[0][this.routeIndex]?.[1] ?? {});
|
|
71501
71307
|
for (const key of keys) {
|
|
71502
71308
|
const value = this.#getParamValue(this.#matchResult[0][this.routeIndex][1][key]);
|
|
71503
|
-
if (value !== void 0)
|
|
71504
|
-
decoded[key] = tryDecodeURIComponent(value);
|
|
71505
|
-
}
|
|
71309
|
+
if (value !== void 0) decoded[key] = tryDecodeURIComponent(value);
|
|
71506
71310
|
}
|
|
71507
71311
|
return decoded;
|
|
71508
71312
|
}
|
|
@@ -71516,9 +71320,7 @@ var HonoRequest = class {
|
|
|
71516
71320
|
return getQueryParams(this.url, key);
|
|
71517
71321
|
}
|
|
71518
71322
|
header(name) {
|
|
71519
|
-
if (name)
|
|
71520
|
-
return this.raw.headers.get(name) ?? void 0;
|
|
71521
|
-
}
|
|
71323
|
+
if (name) return this.raw.headers.get(name) ?? void 0;
|
|
71522
71324
|
const headerData = /* @__PURE__ */ Object.create(null);
|
|
71523
71325
|
this.raw.headers.forEach((value, key) => {
|
|
71524
71326
|
headerData[key] = value;
|
|
@@ -71531,149 +71333,140 @@ var HonoRequest = class {
|
|
|
71531
71333
|
#cachedBody = (key) => {
|
|
71532
71334
|
const { bodyCache, raw: raw2 } = this;
|
|
71533
71335
|
const cachedBody = bodyCache[key];
|
|
71534
|
-
if (cachedBody)
|
|
71535
|
-
|
|
71536
|
-
|
|
71537
|
-
|
|
71538
|
-
return
|
|
71539
|
-
|
|
71540
|
-
body = JSON.stringify(body);
|
|
71541
|
-
}
|
|
71542
|
-
const contentType = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
|
|
71543
|
-
return new Response(body, {
|
|
71544
|
-
headers: contentType ? { "Content-Type": contentType } : void 0
|
|
71545
|
-
})[key]();
|
|
71546
|
-
});
|
|
71547
|
-
}
|
|
71336
|
+
if (cachedBody) return cachedBody;
|
|
71337
|
+
for (const anyCachedKey in bodyCache) return bodyCache[anyCachedKey].then((body) => {
|
|
71338
|
+
if (anyCachedKey === "json") body = JSON.stringify(body);
|
|
71339
|
+
const contentType = anyCachedKey === "formData" ? void 0 : raw2.headers.get("content-type");
|
|
71340
|
+
return new Response(body, { headers: contentType ? { "Content-Type": contentType } : void 0 })[key]();
|
|
71341
|
+
});
|
|
71548
71342
|
return bodyCache[key] = raw2[key]();
|
|
71549
71343
|
};
|
|
71550
71344
|
/**
|
|
71551
|
-
|
|
71552
|
-
|
|
71553
|
-
|
|
71554
|
-
|
|
71555
|
-
|
|
71556
|
-
|
|
71557
|
-
|
|
71558
|
-
|
|
71559
|
-
|
|
71560
|
-
|
|
71561
|
-
|
|
71345
|
+
* `.json()` can parse Request body of type `application/json`
|
|
71346
|
+
*
|
|
71347
|
+
* @see {@link https://hono.dev/docs/api/request#json}
|
|
71348
|
+
*
|
|
71349
|
+
* @example
|
|
71350
|
+
* ```ts
|
|
71351
|
+
* app.post('/entry', async (c) => {
|
|
71352
|
+
* const body = await c.req.json()
|
|
71353
|
+
* })
|
|
71354
|
+
* ```
|
|
71355
|
+
*/
|
|
71562
71356
|
json() {
|
|
71563
71357
|
return this.#cachedBody("text").then((text) => JSON.parse(text));
|
|
71564
71358
|
}
|
|
71565
71359
|
/**
|
|
71566
|
-
|
|
71567
|
-
|
|
71568
|
-
|
|
71569
|
-
|
|
71570
|
-
|
|
71571
|
-
|
|
71572
|
-
|
|
71573
|
-
|
|
71574
|
-
|
|
71575
|
-
|
|
71576
|
-
|
|
71360
|
+
* `.text()` can parse Request body of type `text/plain`
|
|
71361
|
+
*
|
|
71362
|
+
* @see {@link https://hono.dev/docs/api/request#text}
|
|
71363
|
+
*
|
|
71364
|
+
* @example
|
|
71365
|
+
* ```ts
|
|
71366
|
+
* app.post('/entry', async (c) => {
|
|
71367
|
+
* const body = await c.req.text()
|
|
71368
|
+
* })
|
|
71369
|
+
* ```
|
|
71370
|
+
*/
|
|
71577
71371
|
text() {
|
|
71578
71372
|
return this.#cachedBody("text");
|
|
71579
71373
|
}
|
|
71580
71374
|
/**
|
|
71581
|
-
|
|
71582
|
-
|
|
71583
|
-
|
|
71584
|
-
|
|
71585
|
-
|
|
71586
|
-
|
|
71587
|
-
|
|
71588
|
-
|
|
71589
|
-
|
|
71590
|
-
|
|
71591
|
-
|
|
71375
|
+
* `.arrayBuffer()` parse Request body as an `ArrayBuffer`
|
|
71376
|
+
*
|
|
71377
|
+
* @see {@link https://hono.dev/docs/api/request#arraybuffer}
|
|
71378
|
+
*
|
|
71379
|
+
* @example
|
|
71380
|
+
* ```ts
|
|
71381
|
+
* app.post('/entry', async (c) => {
|
|
71382
|
+
* const body = await c.req.arrayBuffer()
|
|
71383
|
+
* })
|
|
71384
|
+
* ```
|
|
71385
|
+
*/
|
|
71592
71386
|
arrayBuffer() {
|
|
71593
71387
|
return this.#cachedBody("arrayBuffer");
|
|
71594
71388
|
}
|
|
71595
71389
|
/**
|
|
71596
|
-
|
|
71597
|
-
|
|
71598
|
-
|
|
71599
|
-
|
|
71600
|
-
|
|
71601
|
-
|
|
71602
|
-
|
|
71603
|
-
|
|
71604
|
-
|
|
71605
|
-
|
|
71606
|
-
|
|
71390
|
+
* `.bytes()` parses the request body as a `Uint8Array`.
|
|
71391
|
+
*
|
|
71392
|
+
* @see {@link https://hono.dev/docs/api/request#bytes}
|
|
71393
|
+
*
|
|
71394
|
+
* @example
|
|
71395
|
+
* ```ts
|
|
71396
|
+
* app.post('/entry', async (c) => {
|
|
71397
|
+
* const body = await c.req.bytes()
|
|
71398
|
+
* })
|
|
71399
|
+
* ```
|
|
71400
|
+
*/
|
|
71607
71401
|
bytes() {
|
|
71608
71402
|
return this.#cachedBody("arrayBuffer").then((buffer) => new Uint8Array(buffer));
|
|
71609
71403
|
}
|
|
71610
71404
|
/**
|
|
71611
|
-
|
|
71612
|
-
|
|
71613
|
-
|
|
71614
|
-
|
|
71615
|
-
|
|
71616
|
-
|
|
71617
|
-
|
|
71618
|
-
|
|
71619
|
-
|
|
71405
|
+
* Parses the request body as a `Blob`.
|
|
71406
|
+
* @example
|
|
71407
|
+
* ```ts
|
|
71408
|
+
* app.post('/entry', async (c) => {
|
|
71409
|
+
* const body = await c.req.blob();
|
|
71410
|
+
* });
|
|
71411
|
+
* ```
|
|
71412
|
+
* @see https://hono.dev/docs/api/request#blob
|
|
71413
|
+
*/
|
|
71620
71414
|
blob() {
|
|
71621
71415
|
return this.#cachedBody("blob");
|
|
71622
71416
|
}
|
|
71623
71417
|
/**
|
|
71624
|
-
|
|
71625
|
-
|
|
71626
|
-
|
|
71627
|
-
|
|
71628
|
-
|
|
71629
|
-
|
|
71630
|
-
|
|
71631
|
-
|
|
71632
|
-
|
|
71418
|
+
* Parses the request body as `FormData`.
|
|
71419
|
+
* @example
|
|
71420
|
+
* ```ts
|
|
71421
|
+
* app.post('/entry', async (c) => {
|
|
71422
|
+
* const body = await c.req.formData();
|
|
71423
|
+
* });
|
|
71424
|
+
* ```
|
|
71425
|
+
* @see https://hono.dev/docs/api/request#formdata
|
|
71426
|
+
*/
|
|
71633
71427
|
formData() {
|
|
71634
71428
|
return this.#cachedBody("formData");
|
|
71635
71429
|
}
|
|
71636
71430
|
/**
|
|
71637
|
-
|
|
71638
|
-
|
|
71639
|
-
|
|
71640
|
-
|
|
71641
|
-
|
|
71431
|
+
* Adds validated data to the request.
|
|
71432
|
+
*
|
|
71433
|
+
* @param target - The target of the validation.
|
|
71434
|
+
* @param data - The validated data to add.
|
|
71435
|
+
*/
|
|
71642
71436
|
addValidatedData(target, data) {
|
|
71643
|
-
;
|
|
71644
71437
|
(this.#validatedData ??= {})[target] = data;
|
|
71645
71438
|
}
|
|
71646
71439
|
valid(target) {
|
|
71647
71440
|
return this.#validatedData?.[target];
|
|
71648
71441
|
}
|
|
71649
71442
|
/**
|
|
71650
|
-
|
|
71651
|
-
|
|
71652
|
-
|
|
71653
|
-
|
|
71654
|
-
|
|
71655
|
-
|
|
71656
|
-
|
|
71657
|
-
|
|
71658
|
-
|
|
71659
|
-
|
|
71660
|
-
|
|
71661
|
-
|
|
71443
|
+
* `.url()` can get the request url strings.
|
|
71444
|
+
*
|
|
71445
|
+
* @see {@link https://hono.dev/docs/api/request#url}
|
|
71446
|
+
*
|
|
71447
|
+
* @example
|
|
71448
|
+
* ```ts
|
|
71449
|
+
* app.get('/about/me', (c) => {
|
|
71450
|
+
* const url = c.req.url // `http://localhost:8787/about/me`
|
|
71451
|
+
* ...
|
|
71452
|
+
* })
|
|
71453
|
+
* ```
|
|
71454
|
+
*/
|
|
71662
71455
|
get url() {
|
|
71663
71456
|
return this.raw.url;
|
|
71664
71457
|
}
|
|
71665
71458
|
/**
|
|
71666
|
-
|
|
71667
|
-
|
|
71668
|
-
|
|
71669
|
-
|
|
71670
|
-
|
|
71671
|
-
|
|
71672
|
-
|
|
71673
|
-
|
|
71674
|
-
|
|
71675
|
-
|
|
71676
|
-
|
|
71459
|
+
* `.method()` can get the method name of the request.
|
|
71460
|
+
*
|
|
71461
|
+
* @see {@link https://hono.dev/docs/api/request#method}
|
|
71462
|
+
*
|
|
71463
|
+
* @example
|
|
71464
|
+
* ```ts
|
|
71465
|
+
* app.get('/about/me', (c) => {
|
|
71466
|
+
* const method = c.req.method // `GET`
|
|
71467
|
+
* })
|
|
71468
|
+
* ```
|
|
71469
|
+
*/
|
|
71677
71470
|
get method() {
|
|
71678
71471
|
return this.raw.method;
|
|
71679
71472
|
}
|
|
@@ -71681,51 +71474,51 @@ var HonoRequest = class {
|
|
|
71681
71474
|
return this.#matchResult;
|
|
71682
71475
|
}
|
|
71683
71476
|
/**
|
|
71684
|
-
|
|
71685
|
-
|
|
71686
|
-
|
|
71687
|
-
|
|
71688
|
-
|
|
71689
|
-
|
|
71690
|
-
|
|
71691
|
-
|
|
71692
|
-
|
|
71693
|
-
|
|
71694
|
-
|
|
71695
|
-
|
|
71696
|
-
|
|
71697
|
-
|
|
71698
|
-
|
|
71699
|
-
|
|
71700
|
-
|
|
71701
|
-
|
|
71702
|
-
|
|
71703
|
-
|
|
71704
|
-
|
|
71705
|
-
|
|
71706
|
-
|
|
71707
|
-
|
|
71708
|
-
|
|
71709
|
-
|
|
71477
|
+
* `.matchedRoutes()` can return a matched route in the handler
|
|
71478
|
+
*
|
|
71479
|
+
* @deprecated
|
|
71480
|
+
*
|
|
71481
|
+
* Use matchedRoutes helper defined in "hono/route" instead.
|
|
71482
|
+
*
|
|
71483
|
+
* @see {@link https://hono.dev/docs/api/request#matchedroutes}
|
|
71484
|
+
*
|
|
71485
|
+
* @example
|
|
71486
|
+
* ```ts
|
|
71487
|
+
* app.use('*', async function logger(c, next) {
|
|
71488
|
+
* await next()
|
|
71489
|
+
* c.req.matchedRoutes.forEach(({ handler, method, path }, i) => {
|
|
71490
|
+
* const name = handler.name || (handler.length < 2 ? '[handler]' : '[middleware]')
|
|
71491
|
+
* console.log(
|
|
71492
|
+
* method,
|
|
71493
|
+
* ' ',
|
|
71494
|
+
* path,
|
|
71495
|
+
* ' '.repeat(Math.max(10 - path.length, 0)),
|
|
71496
|
+
* name,
|
|
71497
|
+
* i === c.req.routeIndex ? '<- respond from here' : ''
|
|
71498
|
+
* )
|
|
71499
|
+
* })
|
|
71500
|
+
* })
|
|
71501
|
+
* ```
|
|
71502
|
+
*/
|
|
71710
71503
|
get matchedRoutes() {
|
|
71711
71504
|
return this.#matchResult[0].map(([[, route]]) => route);
|
|
71712
71505
|
}
|
|
71713
71506
|
/**
|
|
71714
|
-
|
|
71715
|
-
|
|
71716
|
-
|
|
71717
|
-
|
|
71718
|
-
|
|
71719
|
-
|
|
71720
|
-
|
|
71721
|
-
|
|
71722
|
-
|
|
71723
|
-
|
|
71724
|
-
|
|
71725
|
-
|
|
71726
|
-
|
|
71727
|
-
|
|
71728
|
-
|
|
71507
|
+
* `routePath()` can retrieve the path registered within the handler
|
|
71508
|
+
*
|
|
71509
|
+
* @deprecated
|
|
71510
|
+
*
|
|
71511
|
+
* Use routePath helper defined in "hono/route" instead.
|
|
71512
|
+
*
|
|
71513
|
+
* @see {@link https://hono.dev/docs/api/request#routepath}
|
|
71514
|
+
*
|
|
71515
|
+
* @example
|
|
71516
|
+
* ```ts
|
|
71517
|
+
* app.get('/posts/:id', (c) => {
|
|
71518
|
+
* return c.json({ path: c.req.routePath })
|
|
71519
|
+
* })
|
|
71520
|
+
* ```
|
|
71521
|
+
*/
|
|
71729
71522
|
get routePath() {
|
|
71730
71523
|
return this.#matchResult[0].map(([[, route]]) => route)[this.routeIndex].path;
|
|
71731
71524
|
}
|
|
@@ -71745,32 +71538,20 @@ var raw = (value, callbacks) => {
|
|
|
71745
71538
|
};
|
|
71746
71539
|
var resolveCallback = async (str, phase, preserveCallbacks, context, buffer) => {
|
|
71747
71540
|
if (typeof str === "object" && !(str instanceof String)) {
|
|
71748
|
-
if (!(str instanceof Promise))
|
|
71749
|
-
|
|
71750
|
-
}
|
|
71751
|
-
if (str instanceof Promise) {
|
|
71752
|
-
str = await str;
|
|
71753
|
-
}
|
|
71541
|
+
if (!(str instanceof Promise)) str = str.toString();
|
|
71542
|
+
if (str instanceof Promise) str = await str;
|
|
71754
71543
|
}
|
|
71755
71544
|
const callbacks = str.callbacks;
|
|
71756
|
-
if (!callbacks?.length)
|
|
71757
|
-
|
|
71758
|
-
|
|
71759
|
-
|
|
71760
|
-
|
|
71761
|
-
|
|
71762
|
-
|
|
71763
|
-
}
|
|
71764
|
-
|
|
71765
|
-
|
|
71766
|
-
res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))
|
|
71767
|
-
).then(() => buffer[0])
|
|
71768
|
-
);
|
|
71769
|
-
if (preserveCallbacks) {
|
|
71770
|
-
return raw(await resStr, callbacks);
|
|
71771
|
-
} else {
|
|
71772
|
-
return resStr;
|
|
71773
|
-
}
|
|
71545
|
+
if (!callbacks?.length) return Promise.resolve(str);
|
|
71546
|
+
if (buffer) buffer[0] += str;
|
|
71547
|
+
else buffer = [str];
|
|
71548
|
+
const resStr = Promise.all(callbacks.map((c5) => c5({
|
|
71549
|
+
phase,
|
|
71550
|
+
buffer,
|
|
71551
|
+
context
|
|
71552
|
+
}))).then((res) => Promise.all(res.filter(Boolean).map((str2) => resolveCallback(str2, phase, false, context, buffer))).then(() => buffer[0]));
|
|
71553
|
+
if (preserveCallbacks) return raw(await resStr, callbacks);
|
|
71554
|
+
else return resStr;
|
|
71774
71555
|
};
|
|
71775
71556
|
|
|
71776
71557
|
// node_modules/hono/dist/context.js
|
|
@@ -71786,36 +71567,36 @@ var Context = class {
|
|
|
71786
71567
|
#rawRequest;
|
|
71787
71568
|
#req;
|
|
71788
71569
|
/**
|
|
71789
|
-
|
|
71790
|
-
|
|
71791
|
-
|
|
71792
|
-
|
|
71793
|
-
|
|
71794
|
-
|
|
71795
|
-
|
|
71796
|
-
|
|
71797
|
-
|
|
71798
|
-
|
|
71799
|
-
|
|
71800
|
-
|
|
71570
|
+
* `.env` can get bindings (environment variables, secrets, KV namespaces, D1 database, R2 bucket etc.) in Cloudflare Workers.
|
|
71571
|
+
*
|
|
71572
|
+
* @see {@link https://hono.dev/docs/api/context#env}
|
|
71573
|
+
*
|
|
71574
|
+
* @example
|
|
71575
|
+
* ```ts
|
|
71576
|
+
* // Environment object for Cloudflare Workers
|
|
71577
|
+
* app.get('*', async c => {
|
|
71578
|
+
* const counter = c.env.COUNTER
|
|
71579
|
+
* })
|
|
71580
|
+
* ```
|
|
71581
|
+
*/
|
|
71801
71582
|
env = {};
|
|
71802
71583
|
#var;
|
|
71803
71584
|
finalized = false;
|
|
71804
71585
|
/**
|
|
71805
|
-
|
|
71806
|
-
|
|
71807
|
-
|
|
71808
|
-
|
|
71809
|
-
|
|
71810
|
-
|
|
71811
|
-
|
|
71812
|
-
|
|
71813
|
-
|
|
71814
|
-
|
|
71815
|
-
|
|
71816
|
-
|
|
71817
|
-
|
|
71818
|
-
|
|
71586
|
+
* `.error` can get the error object from the middleware if the Handler throws an error.
|
|
71587
|
+
*
|
|
71588
|
+
* @see {@link https://hono.dev/docs/api/context#error}
|
|
71589
|
+
*
|
|
71590
|
+
* @example
|
|
71591
|
+
* ```ts
|
|
71592
|
+
* app.use('*', async (c, next) => {
|
|
71593
|
+
* await next()
|
|
71594
|
+
* if (c.error) {
|
|
71595
|
+
* // do something...
|
|
71596
|
+
* }
|
|
71597
|
+
* })
|
|
71598
|
+
* ```
|
|
71599
|
+
*/
|
|
71819
71600
|
error;
|
|
71820
71601
|
#status;
|
|
71821
71602
|
#executionCtx;
|
|
@@ -71827,11 +71608,11 @@ var Context = class {
|
|
|
71827
71608
|
#matchResult;
|
|
71828
71609
|
#path;
|
|
71829
71610
|
/**
|
|
71830
|
-
|
|
71831
|
-
|
|
71832
|
-
|
|
71833
|
-
|
|
71834
|
-
|
|
71611
|
+
* Creates an instance of the Context class.
|
|
71612
|
+
*
|
|
71613
|
+
* @param req - The Request object.
|
|
71614
|
+
* @param options - Optional configuration options for the context.
|
|
71615
|
+
*/
|
|
71835
71616
|
constructor(req, options) {
|
|
71836
71617
|
this.#rawRequest = req;
|
|
71837
71618
|
if (options) {
|
|
@@ -71843,245 +71624,210 @@ var Context = class {
|
|
|
71843
71624
|
}
|
|
71844
71625
|
}
|
|
71845
71626
|
/**
|
|
71846
|
-
|
|
71847
|
-
|
|
71627
|
+
* `.req` is the instance of {@link HonoRequest}.
|
|
71628
|
+
*/
|
|
71848
71629
|
get req() {
|
|
71849
71630
|
this.#req ??= new HonoRequest(this.#rawRequest, this.#path, this.#matchResult);
|
|
71850
71631
|
return this.#req;
|
|
71851
71632
|
}
|
|
71852
71633
|
/**
|
|
71853
|
-
|
|
71854
|
-
|
|
71855
|
-
|
|
71856
|
-
|
|
71857
|
-
|
|
71634
|
+
* @see {@link https://hono.dev/docs/api/context#event}
|
|
71635
|
+
* The FetchEvent associated with the current request.
|
|
71636
|
+
*
|
|
71637
|
+
* @throws Will throw an error if the context does not have a FetchEvent.
|
|
71638
|
+
*/
|
|
71858
71639
|
get event() {
|
|
71859
|
-
if (this.#executionCtx && "respondWith" in this.#executionCtx)
|
|
71860
|
-
|
|
71861
|
-
} else {
|
|
71862
|
-
throw Error("This context has no FetchEvent");
|
|
71863
|
-
}
|
|
71640
|
+
if (this.#executionCtx && "respondWith" in this.#executionCtx) return this.#executionCtx;
|
|
71641
|
+
else throw Error("This context has no FetchEvent");
|
|
71864
71642
|
}
|
|
71865
71643
|
/**
|
|
71866
|
-
|
|
71867
|
-
|
|
71868
|
-
|
|
71869
|
-
|
|
71870
|
-
|
|
71644
|
+
* @see {@link https://hono.dev/docs/api/context#executionctx}
|
|
71645
|
+
* The ExecutionContext associated with the current request.
|
|
71646
|
+
*
|
|
71647
|
+
* @throws Will throw an error if the context does not have an ExecutionContext.
|
|
71648
|
+
*/
|
|
71871
71649
|
get executionCtx() {
|
|
71872
|
-
if (this.#executionCtx)
|
|
71873
|
-
|
|
71874
|
-
} else {
|
|
71875
|
-
throw Error("This context has no ExecutionContext");
|
|
71876
|
-
}
|
|
71650
|
+
if (this.#executionCtx) return this.#executionCtx;
|
|
71651
|
+
else throw Error("This context has no ExecutionContext");
|
|
71877
71652
|
}
|
|
71878
71653
|
/**
|
|
71879
|
-
|
|
71880
|
-
|
|
71881
|
-
|
|
71654
|
+
* @see {@link https://hono.dev/docs/api/context#res}
|
|
71655
|
+
* The Response object for the current request.
|
|
71656
|
+
*/
|
|
71882
71657
|
get res() {
|
|
71883
|
-
return this.#res ||= createResponseInstance(null, {
|
|
71884
|
-
headers: this.#preparedHeaders ??= new Headers()
|
|
71885
|
-
});
|
|
71658
|
+
return this.#res ||= createResponseInstance(null, { headers: this.#preparedHeaders ??= new Headers() });
|
|
71886
71659
|
}
|
|
71887
71660
|
/**
|
|
71888
|
-
|
|
71889
|
-
|
|
71890
|
-
|
|
71891
|
-
|
|
71661
|
+
* Sets the Response object for the current request.
|
|
71662
|
+
*
|
|
71663
|
+
* @param _res - The Response object to set.
|
|
71664
|
+
*/
|
|
71892
71665
|
set res(_res) {
|
|
71893
71666
|
if (this.#res && _res) {
|
|
71894
71667
|
_res = createResponseInstance(_res.body, _res);
|
|
71895
71668
|
for (const [k5, v] of this.#res.headers.entries()) {
|
|
71896
|
-
if (k5 === "content-type")
|
|
71897
|
-
continue;
|
|
71898
|
-
}
|
|
71669
|
+
if (k5 === "content-type") continue;
|
|
71899
71670
|
if (k5 === "set-cookie") {
|
|
71900
71671
|
const cookies = this.#res.headers.getSetCookie();
|
|
71901
71672
|
_res.headers.delete("set-cookie");
|
|
71902
|
-
for (const cookie of cookies)
|
|
71903
|
-
|
|
71904
|
-
}
|
|
71905
|
-
} else {
|
|
71906
|
-
_res.headers.set(k5, v);
|
|
71907
|
-
}
|
|
71673
|
+
for (const cookie of cookies) _res.headers.append("set-cookie", cookie);
|
|
71674
|
+
} else _res.headers.set(k5, v);
|
|
71908
71675
|
}
|
|
71909
71676
|
}
|
|
71910
71677
|
this.#res = _res;
|
|
71911
71678
|
this.finalized = true;
|
|
71912
71679
|
}
|
|
71913
71680
|
/**
|
|
71914
|
-
|
|
71915
|
-
|
|
71916
|
-
|
|
71917
|
-
|
|
71918
|
-
|
|
71919
|
-
|
|
71920
|
-
|
|
71921
|
-
|
|
71922
|
-
|
|
71923
|
-
|
|
71924
|
-
|
|
71681
|
+
* `.render()` can create a response within a layout.
|
|
71682
|
+
*
|
|
71683
|
+
* @see {@link https://hono.dev/docs/api/context#render-setrenderer}
|
|
71684
|
+
*
|
|
71685
|
+
* @example
|
|
71686
|
+
* ```ts
|
|
71687
|
+
* app.get('/', (c) => {
|
|
71688
|
+
* return c.render('Hello!')
|
|
71689
|
+
* })
|
|
71690
|
+
* ```
|
|
71691
|
+
*/
|
|
71925
71692
|
render = (...args) => {
|
|
71926
71693
|
this.#renderer ??= (content) => this.html(content);
|
|
71927
71694
|
return this.#renderer(...args);
|
|
71928
71695
|
};
|
|
71929
71696
|
/**
|
|
71930
|
-
|
|
71931
|
-
|
|
71932
|
-
|
|
71933
|
-
|
|
71934
|
-
|
|
71697
|
+
* Sets the layout for the response.
|
|
71698
|
+
*
|
|
71699
|
+
* @param layout - The layout to set.
|
|
71700
|
+
* @returns The layout function.
|
|
71701
|
+
*/
|
|
71935
71702
|
setLayout = (layout) => this.#layout = layout;
|
|
71936
71703
|
/**
|
|
71937
|
-
|
|
71938
|
-
|
|
71939
|
-
|
|
71940
|
-
|
|
71704
|
+
* Gets the current layout for the response.
|
|
71705
|
+
*
|
|
71706
|
+
* @returns The current layout function.
|
|
71707
|
+
*/
|
|
71941
71708
|
getLayout = () => this.#layout;
|
|
71942
71709
|
/**
|
|
71943
|
-
|
|
71944
|
-
|
|
71945
|
-
|
|
71946
|
-
|
|
71947
|
-
|
|
71948
|
-
|
|
71949
|
-
|
|
71950
|
-
|
|
71951
|
-
|
|
71952
|
-
|
|
71953
|
-
|
|
71954
|
-
|
|
71955
|
-
|
|
71956
|
-
|
|
71957
|
-
|
|
71958
|
-
|
|
71959
|
-
|
|
71960
|
-
|
|
71961
|
-
|
|
71962
|
-
|
|
71710
|
+
* `.setRenderer()` can set the layout in the custom middleware.
|
|
71711
|
+
*
|
|
71712
|
+
* @see {@link https://hono.dev/docs/api/context#render-setrenderer}
|
|
71713
|
+
*
|
|
71714
|
+
* @example
|
|
71715
|
+
* ```tsx
|
|
71716
|
+
* app.use('*', async (c, next) => {
|
|
71717
|
+
* c.setRenderer((content) => {
|
|
71718
|
+
* return c.html(
|
|
71719
|
+
* <html>
|
|
71720
|
+
* <body>
|
|
71721
|
+
* <p>{content}</p>
|
|
71722
|
+
* </body>
|
|
71723
|
+
* </html>
|
|
71724
|
+
* )
|
|
71725
|
+
* })
|
|
71726
|
+
* await next()
|
|
71727
|
+
* })
|
|
71728
|
+
* ```
|
|
71729
|
+
*/
|
|
71963
71730
|
setRenderer = (renderer) => {
|
|
71964
71731
|
this.#renderer = renderer;
|
|
71965
71732
|
};
|
|
71966
71733
|
/**
|
|
71967
|
-
|
|
71968
|
-
|
|
71969
|
-
|
|
71970
|
-
|
|
71971
|
-
|
|
71972
|
-
|
|
71973
|
-
|
|
71974
|
-
|
|
71975
|
-
|
|
71976
|
-
|
|
71977
|
-
|
|
71978
|
-
|
|
71979
|
-
|
|
71980
|
-
|
|
71981
|
-
|
|
71982
|
-
|
|
71983
|
-
|
|
71984
|
-
|
|
71985
|
-
|
|
71734
|
+
* `.header()` can set headers.
|
|
71735
|
+
*
|
|
71736
|
+
* @see {@link https://hono.dev/docs/api/context#header}
|
|
71737
|
+
*
|
|
71738
|
+
* @example
|
|
71739
|
+
* ```ts
|
|
71740
|
+
* app.get('/welcome', (c) => {
|
|
71741
|
+
* // Set headers
|
|
71742
|
+
* c.header('X-Message', 'Hello!')
|
|
71743
|
+
* c.header('Content-Type', 'text/plain')
|
|
71744
|
+
*
|
|
71745
|
+
* // Append multiple headers using the append option (e.g. Vary)
|
|
71746
|
+
* c.header('Vary', 'Accept-Encoding', { append: true })
|
|
71747
|
+
* c.header('Vary', 'User-Agent', { append: true })
|
|
71748
|
+
*
|
|
71749
|
+
* return c.body('Thank you for coming')
|
|
71750
|
+
* })
|
|
71751
|
+
* ```
|
|
71752
|
+
*/
|
|
71986
71753
|
header = (name, value, options) => {
|
|
71987
|
-
if (this.finalized)
|
|
71988
|
-
this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
71989
|
-
}
|
|
71754
|
+
if (this.finalized) this.#res = createResponseInstance(this.#res.body, this.#res);
|
|
71990
71755
|
const headers = this.#res ? this.#res.headers : this.#preparedHeaders ??= new Headers();
|
|
71991
|
-
if (value === void 0)
|
|
71992
|
-
|
|
71993
|
-
|
|
71994
|
-
headers.append(name, value);
|
|
71995
|
-
} else {
|
|
71996
|
-
headers.set(name, value);
|
|
71997
|
-
}
|
|
71756
|
+
if (value === void 0) headers.delete(name);
|
|
71757
|
+
else if (options?.append) headers.append(name, value);
|
|
71758
|
+
else headers.set(name, value);
|
|
71998
71759
|
};
|
|
71999
71760
|
status = (status) => {
|
|
72000
71761
|
this.#status = status;
|
|
72001
71762
|
};
|
|
72002
71763
|
/**
|
|
72003
|
-
|
|
72004
|
-
|
|
72005
|
-
|
|
72006
|
-
|
|
72007
|
-
|
|
72008
|
-
|
|
72009
|
-
|
|
72010
|
-
|
|
72011
|
-
|
|
72012
|
-
|
|
72013
|
-
|
|
72014
|
-
|
|
71764
|
+
* `.set()` can set the value specified by the key.
|
|
71765
|
+
*
|
|
71766
|
+
* @see {@link https://hono.dev/docs/api/context#set-get}
|
|
71767
|
+
*
|
|
71768
|
+
* @example
|
|
71769
|
+
* ```ts
|
|
71770
|
+
* app.use('*', async (c, next) => {
|
|
71771
|
+
* c.set('message', 'Hono is hot!!')
|
|
71772
|
+
* await next()
|
|
71773
|
+
* })
|
|
71774
|
+
* ```
|
|
71775
|
+
*/
|
|
72015
71776
|
set = (key, value) => {
|
|
72016
71777
|
this.#var ??= /* @__PURE__ */ new Map();
|
|
72017
71778
|
this.#var.set(key, value);
|
|
72018
71779
|
};
|
|
72019
71780
|
/**
|
|
72020
|
-
|
|
72021
|
-
|
|
72022
|
-
|
|
72023
|
-
|
|
72024
|
-
|
|
72025
|
-
|
|
72026
|
-
|
|
72027
|
-
|
|
72028
|
-
|
|
72029
|
-
|
|
72030
|
-
|
|
72031
|
-
|
|
71781
|
+
* `.get()` can use the value specified by the key.
|
|
71782
|
+
*
|
|
71783
|
+
* @see {@link https://hono.dev/docs/api/context#set-get}
|
|
71784
|
+
*
|
|
71785
|
+
* @example
|
|
71786
|
+
* ```ts
|
|
71787
|
+
* app.get('/', (c) => {
|
|
71788
|
+
* const message = c.get('message')
|
|
71789
|
+
* return c.text(`The message is "${message}"`)
|
|
71790
|
+
* })
|
|
71791
|
+
* ```
|
|
71792
|
+
*/
|
|
72032
71793
|
get = (key) => {
|
|
72033
71794
|
return this.#var ? this.#var.get(key) : void 0;
|
|
72034
71795
|
};
|
|
72035
71796
|
/**
|
|
72036
|
-
|
|
72037
|
-
|
|
72038
|
-
|
|
72039
|
-
|
|
72040
|
-
|
|
72041
|
-
|
|
72042
|
-
|
|
72043
|
-
|
|
72044
|
-
|
|
72045
|
-
// c.var.propName is a read-only
|
|
71797
|
+
* `.var` can access the value of a variable.
|
|
71798
|
+
*
|
|
71799
|
+
* @see {@link https://hono.dev/docs/api/context#var}
|
|
71800
|
+
*
|
|
71801
|
+
* @example
|
|
71802
|
+
* ```ts
|
|
71803
|
+
* const result = c.var.client.oneMethod()
|
|
71804
|
+
* ```
|
|
71805
|
+
*/
|
|
72046
71806
|
get var() {
|
|
72047
|
-
if (!this.#var) {
|
|
72048
|
-
return {};
|
|
72049
|
-
}
|
|
71807
|
+
if (!this.#var) return {};
|
|
72050
71808
|
return Object.fromEntries(this.#var);
|
|
72051
71809
|
}
|
|
72052
71810
|
#newResponse(data, arg, headers) {
|
|
72053
71811
|
let responseHeaders = this.#res ? new Headers(this.#res.headers) : this.#preparedHeaders;
|
|
72054
71812
|
if (typeof arg === "object" && arg.headers) {
|
|
72055
71813
|
responseHeaders ??= new Headers();
|
|
72056
|
-
for (const [key, value] of new Headers(arg.headers))
|
|
72057
|
-
|
|
72058
|
-
responseHeaders.append(key, value);
|
|
72059
|
-
} else {
|
|
72060
|
-
responseHeaders.set(key, value);
|
|
72061
|
-
}
|
|
72062
|
-
}
|
|
71814
|
+
for (const [key, value] of new Headers(arg.headers)) if (key === "set-cookie") responseHeaders.append(key, value);
|
|
71815
|
+
else responseHeaders.set(key, value);
|
|
72063
71816
|
}
|
|
72064
71817
|
if (headers) {
|
|
72065
71818
|
if (!responseHeaders) {
|
|
72066
71819
|
let count = 0;
|
|
72067
|
-
for (const k5 in headers) {
|
|
72068
|
-
|
|
72069
|
-
|
|
72070
|
-
break;
|
|
72071
|
-
}
|
|
71820
|
+
for (const k5 in headers) if (++count > 1 || typeof headers[k5] !== "string") {
|
|
71821
|
+
responseHeaders = new Headers();
|
|
71822
|
+
break;
|
|
72072
71823
|
}
|
|
72073
71824
|
}
|
|
72074
|
-
if (responseHeaders) {
|
|
72075
|
-
|
|
72076
|
-
|
|
72077
|
-
|
|
72078
|
-
|
|
72079
|
-
|
|
72080
|
-
responseHeaders.delete(k5);
|
|
72081
|
-
for (const v2 of v) {
|
|
72082
|
-
responseHeaders.append(k5, v2);
|
|
72083
|
-
}
|
|
72084
|
-
}
|
|
71825
|
+
if (responseHeaders) for (const k5 in headers) {
|
|
71826
|
+
const v = headers[k5];
|
|
71827
|
+
if (typeof v === "string") responseHeaders.set(k5, v);
|
|
71828
|
+
else {
|
|
71829
|
+
responseHeaders.delete(k5);
|
|
71830
|
+
for (const v2 of v) responseHeaders.append(k5, v2);
|
|
72085
71831
|
}
|
|
72086
71832
|
}
|
|
72087
71833
|
}
|
|
@@ -72093,116 +71839,140 @@ var Context = class {
|
|
|
72093
71839
|
}
|
|
72094
71840
|
newResponse = (...args) => this.#newResponse(...args);
|
|
72095
71841
|
/**
|
|
72096
|
-
|
|
72097
|
-
|
|
72098
|
-
|
|
72099
|
-
|
|
72100
|
-
|
|
72101
|
-
|
|
72102
|
-
|
|
72103
|
-
|
|
72104
|
-
|
|
72105
|
-
|
|
72106
|
-
|
|
72107
|
-
|
|
72108
|
-
|
|
72109
|
-
|
|
72110
|
-
|
|
72111
|
-
|
|
72112
|
-
|
|
72113
|
-
|
|
72114
|
-
|
|
72115
|
-
|
|
71842
|
+
* `.body()` can return the HTTP response.
|
|
71843
|
+
* You can set headers with `.header()` and set HTTP status code with `.status`.
|
|
71844
|
+
* This can also be set in `.text()`, `.json()` and so on.
|
|
71845
|
+
*
|
|
71846
|
+
* @see {@link https://hono.dev/docs/api/context#body}
|
|
71847
|
+
*
|
|
71848
|
+
* @example
|
|
71849
|
+
* ```ts
|
|
71850
|
+
* app.get('/welcome', (c) => {
|
|
71851
|
+
* // Set headers
|
|
71852
|
+
* c.header('X-Message', 'Hello!')
|
|
71853
|
+
* c.header('Content-Type', 'text/plain')
|
|
71854
|
+
* // Set HTTP status code
|
|
71855
|
+
* c.status(201)
|
|
71856
|
+
*
|
|
71857
|
+
* // Return the response body
|
|
71858
|
+
* return c.body('Thank you for coming')
|
|
71859
|
+
* })
|
|
71860
|
+
* ```
|
|
71861
|
+
*/
|
|
72116
71862
|
body = (data, arg, headers) => this.#newResponse(data, arg, headers);
|
|
72117
71863
|
/**
|
|
72118
|
-
|
|
72119
|
-
|
|
72120
|
-
|
|
72121
|
-
|
|
72122
|
-
|
|
72123
|
-
|
|
72124
|
-
|
|
72125
|
-
|
|
72126
|
-
|
|
72127
|
-
|
|
72128
|
-
|
|
71864
|
+
* `.text()` can render text as `Content-Type:text/plain`.
|
|
71865
|
+
*
|
|
71866
|
+
* @see {@link https://hono.dev/docs/api/context#text}
|
|
71867
|
+
*
|
|
71868
|
+
* @example
|
|
71869
|
+
* ```ts
|
|
71870
|
+
* app.get('/say', (c) => {
|
|
71871
|
+
* return c.text('Hello!')
|
|
71872
|
+
* })
|
|
71873
|
+
* ```
|
|
71874
|
+
*/
|
|
72129
71875
|
text = (text, arg, headers) => {
|
|
72130
|
-
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(
|
|
72131
|
-
text,
|
|
72132
|
-
arg,
|
|
72133
|
-
setDefaultContentType(TEXT_PLAIN, headers)
|
|
72134
|
-
);
|
|
71876
|
+
return !this.#preparedHeaders && !this.#status && !arg && !headers && !this.finalized ? new Response(text) : this.#newResponse(text, arg, setDefaultContentType(TEXT_PLAIN, headers));
|
|
72135
71877
|
};
|
|
72136
71878
|
/**
|
|
72137
|
-
|
|
72138
|
-
|
|
72139
|
-
|
|
72140
|
-
|
|
72141
|
-
|
|
72142
|
-
|
|
72143
|
-
|
|
72144
|
-
|
|
72145
|
-
|
|
72146
|
-
|
|
72147
|
-
|
|
71879
|
+
* `.json()` can render JSON as `Content-Type:application/json`.
|
|
71880
|
+
*
|
|
71881
|
+
* @see {@link https://hono.dev/docs/api/context#json}
|
|
71882
|
+
*
|
|
71883
|
+
* @example
|
|
71884
|
+
* ```ts
|
|
71885
|
+
* app.get('/api', (c) => {
|
|
71886
|
+
* return c.json({ message: 'Hello!' })
|
|
71887
|
+
* })
|
|
71888
|
+
* ```
|
|
71889
|
+
*/
|
|
72148
71890
|
json = (object2, arg, headers) => {
|
|
72149
|
-
return this.#newResponse(
|
|
72150
|
-
JSON.stringify(object2),
|
|
72151
|
-
arg,
|
|
72152
|
-
setDefaultContentType("application/json", headers)
|
|
72153
|
-
);
|
|
71891
|
+
return this.#newResponse(JSON.stringify(object2), arg, setDefaultContentType("application/json", headers));
|
|
72154
71892
|
};
|
|
72155
71893
|
html = (html, arg, headers) => {
|
|
72156
71894
|
const res = (html2) => this.#newResponse(html2, arg, setDefaultContentType("text/html; charset=UTF-8", headers));
|
|
72157
71895
|
return typeof html === "object" ? resolveCallback(html, HtmlEscapedCallbackPhase.Stringify, false, {}).then(res) : res(html);
|
|
72158
71896
|
};
|
|
72159
71897
|
/**
|
|
72160
|
-
|
|
72161
|
-
|
|
72162
|
-
|
|
72163
|
-
|
|
72164
|
-
|
|
72165
|
-
|
|
72166
|
-
|
|
72167
|
-
|
|
72168
|
-
|
|
72169
|
-
|
|
72170
|
-
|
|
72171
|
-
|
|
72172
|
-
|
|
72173
|
-
|
|
71898
|
+
* `.redirect()` can Redirect, default status code is 302.
|
|
71899
|
+
*
|
|
71900
|
+
* @see {@link https://hono.dev/docs/api/context#redirect}
|
|
71901
|
+
*
|
|
71902
|
+
* @example
|
|
71903
|
+
* ```ts
|
|
71904
|
+
* app.get('/redirect', (c) => {
|
|
71905
|
+
* return c.redirect('/')
|
|
71906
|
+
* })
|
|
71907
|
+
* app.get('/redirect-permanently', (c) => {
|
|
71908
|
+
* return c.redirect('/', 301)
|
|
71909
|
+
* })
|
|
71910
|
+
* ```
|
|
71911
|
+
*/
|
|
72174
71912
|
redirect = (location, status) => {
|
|
72175
71913
|
const locationString = String(location);
|
|
72176
|
-
this.header(
|
|
72177
|
-
"Location",
|
|
72178
|
-
// Multibytes should be encoded
|
|
72179
|
-
// eslint-disable-next-line no-control-regex
|
|
72180
|
-
!/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString)
|
|
72181
|
-
);
|
|
71914
|
+
this.header("Location", !/[^\x00-\xFF]/.test(locationString) ? locationString : encodeURI(locationString));
|
|
72182
71915
|
return this.newResponse(null, status ?? 302);
|
|
72183
71916
|
};
|
|
72184
71917
|
/**
|
|
72185
|
-
|
|
72186
|
-
|
|
72187
|
-
|
|
72188
|
-
|
|
72189
|
-
|
|
72190
|
-
|
|
72191
|
-
|
|
72192
|
-
|
|
72193
|
-
|
|
72194
|
-
|
|
72195
|
-
|
|
71918
|
+
* `.notFound()` can return the Not Found Response.
|
|
71919
|
+
*
|
|
71920
|
+
* @see {@link https://hono.dev/docs/api/context#notfound}
|
|
71921
|
+
*
|
|
71922
|
+
* @example
|
|
71923
|
+
* ```ts
|
|
71924
|
+
* app.get('/notfound', (c) => {
|
|
71925
|
+
* return c.notFound()
|
|
71926
|
+
* })
|
|
71927
|
+
* ```
|
|
71928
|
+
*/
|
|
72196
71929
|
notFound = () => {
|
|
72197
71930
|
this.#notFoundHandler ??= () => createResponseInstance();
|
|
72198
71931
|
return this.#notFoundHandler(this);
|
|
72199
71932
|
};
|
|
72200
71933
|
};
|
|
72201
71934
|
|
|
71935
|
+
// node_modules/hono/dist/compose.js
|
|
71936
|
+
var compose = (middleware, onError, onNotFound) => {
|
|
71937
|
+
return (context, next) => {
|
|
71938
|
+
let index = -1;
|
|
71939
|
+
return dispatch(0);
|
|
71940
|
+
async function dispatch(i5) {
|
|
71941
|
+
if (i5 <= index) throw new Error("next() called multiple times");
|
|
71942
|
+
index = i5;
|
|
71943
|
+
let res;
|
|
71944
|
+
let isError = false;
|
|
71945
|
+
let handler2;
|
|
71946
|
+
if (middleware[i5]) {
|
|
71947
|
+
handler2 = middleware[i5][0][0];
|
|
71948
|
+
context.req.routeIndex = i5;
|
|
71949
|
+
} else handler2 = i5 === middleware.length && next || void 0;
|
|
71950
|
+
if (handler2) try {
|
|
71951
|
+
res = await handler2(context, () => dispatch(i5 + 1));
|
|
71952
|
+
} catch (err) {
|
|
71953
|
+
if (err instanceof Error && onError) {
|
|
71954
|
+
context.error = err;
|
|
71955
|
+
res = await onError(err, context);
|
|
71956
|
+
isError = true;
|
|
71957
|
+
} else throw err;
|
|
71958
|
+
}
|
|
71959
|
+
else if (context.finalized === false && onNotFound) res = await onNotFound(context);
|
|
71960
|
+
if (res && (context.finalized === false || isError)) context.res = res;
|
|
71961
|
+
return context;
|
|
71962
|
+
}
|
|
71963
|
+
};
|
|
71964
|
+
};
|
|
71965
|
+
|
|
72202
71966
|
// node_modules/hono/dist/router.js
|
|
72203
|
-
var
|
|
72204
|
-
|
|
72205
|
-
|
|
71967
|
+
var METHODS = [
|
|
71968
|
+
"get",
|
|
71969
|
+
"post",
|
|
71970
|
+
"put",
|
|
71971
|
+
"delete",
|
|
71972
|
+
"options",
|
|
71973
|
+
"patch",
|
|
71974
|
+
"query"
|
|
71975
|
+
];
|
|
72206
71976
|
var MESSAGE_MATCHER_IS_ALREADY_BUILT = "Can not add a route since the matcher is already built.";
|
|
72207
71977
|
var UnsupportedPathError = class extends Error {
|
|
72208
71978
|
};
|
|
@@ -72222,7 +71992,7 @@ var errorHandler = (err, c5) => {
|
|
|
72222
71992
|
console.error(err);
|
|
72223
71993
|
return c5.text("Internal Server Error", 500);
|
|
72224
71994
|
};
|
|
72225
|
-
var Hono = class
|
|
71995
|
+
var Hono = class Hono2 {
|
|
72226
71996
|
get;
|
|
72227
71997
|
post;
|
|
72228
71998
|
put;
|
|
@@ -72233,26 +72003,17 @@ var Hono = class _Hono {
|
|
|
72233
72003
|
all;
|
|
72234
72004
|
on;
|
|
72235
72005
|
use;
|
|
72236
|
-
/*
|
|
72237
|
-
This class is like an abstract class and does not have a router.
|
|
72238
|
-
To use it, inherit the class and implement router in the constructor.
|
|
72239
|
-
*/
|
|
72240
72006
|
router;
|
|
72241
72007
|
getPath;
|
|
72242
|
-
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
72243
72008
|
_basePath = "/";
|
|
72244
72009
|
#path = "/";
|
|
72245
72010
|
routes = [];
|
|
72246
72011
|
constructor(options = {}) {
|
|
72247
|
-
|
|
72248
|
-
allMethods.forEach((method) => {
|
|
72012
|
+
[...METHODS, "all"].forEach((method) => {
|
|
72249
72013
|
this[method] = (args1, ...args) => {
|
|
72250
72014
|
const methodName = method.toUpperCase();
|
|
72251
|
-
if (typeof args1 === "string")
|
|
72252
|
-
|
|
72253
|
-
} else {
|
|
72254
|
-
this.#addRoute(methodName, this.#path, args1);
|
|
72255
|
-
}
|
|
72015
|
+
if (typeof args1 === "string") this.#path = args1;
|
|
72016
|
+
else this.#addRoute(methodName, this.#path, args1);
|
|
72256
72017
|
args.forEach((handler2) => {
|
|
72257
72018
|
this.#addRoute(methodName, this.#path, handler2);
|
|
72258
72019
|
});
|
|
@@ -72264,22 +72025,19 @@ var Hono = class _Hono {
|
|
|
72264
72025
|
this.#path = p3;
|
|
72265
72026
|
for (const m3 of [method].flat()) {
|
|
72266
72027
|
const methodName = m3.toUpperCase();
|
|
72267
|
-
for (const handler2 of handlers)
|
|
72268
|
-
this.#addRoute(methodName, this.#path, handler2);
|
|
72269
|
-
}
|
|
72028
|
+
for (const handler2 of handlers) this.#addRoute(methodName, this.#path, handler2);
|
|
72270
72029
|
}
|
|
72271
72030
|
}
|
|
72272
72031
|
return this;
|
|
72273
72032
|
};
|
|
72274
72033
|
this.use = (arg1, ...handlers) => {
|
|
72275
|
-
if (typeof arg1 === "string")
|
|
72276
|
-
|
|
72277
|
-
} else {
|
|
72034
|
+
if (typeof arg1 === "string") this.#path = arg1;
|
|
72035
|
+
else {
|
|
72278
72036
|
this.#path = "*";
|
|
72279
72037
|
handlers.unshift(arg1);
|
|
72280
72038
|
}
|
|
72281
72039
|
handlers.forEach((handler2) => {
|
|
72282
|
-
this.#addRoute(
|
|
72040
|
+
this.#addRoute("ALL", this.#path, handler2);
|
|
72283
72041
|
});
|
|
72284
72042
|
return this;
|
|
72285
72043
|
};
|
|
@@ -72288,7 +72046,7 @@ var Hono = class _Hono {
|
|
|
72288
72046
|
this.getPath = strict ?? true ? options.getPath ?? getPath : getPathNoStrict;
|
|
72289
72047
|
}
|
|
72290
72048
|
#clone() {
|
|
72291
|
-
const clone2 = new
|
|
72049
|
+
const clone2 = new Hono2({
|
|
72292
72050
|
router: this.router,
|
|
72293
72051
|
getPath: this.getPath
|
|
72294
72052
|
});
|
|
@@ -72298,33 +72056,31 @@ var Hono = class _Hono {
|
|
|
72298
72056
|
return clone2;
|
|
72299
72057
|
}
|
|
72300
72058
|
#notFoundHandler = notFoundHandler;
|
|
72301
|
-
// Cannot use `#` because it requires visibility at JavaScript runtime.
|
|
72302
72059
|
errorHandler = errorHandler;
|
|
72303
72060
|
/**
|
|
72304
|
-
|
|
72305
|
-
|
|
72306
|
-
|
|
72307
|
-
|
|
72308
|
-
|
|
72309
|
-
|
|
72310
|
-
|
|
72311
|
-
|
|
72312
|
-
|
|
72313
|
-
|
|
72314
|
-
|
|
72315
|
-
|
|
72316
|
-
|
|
72317
|
-
|
|
72318
|
-
|
|
72319
|
-
|
|
72320
|
-
|
|
72061
|
+
* `.route()` allows grouping other Hono instance in routes.
|
|
72062
|
+
*
|
|
72063
|
+
* @see {@link https://hono.dev/docs/api/routing#grouping}
|
|
72064
|
+
*
|
|
72065
|
+
* @param {string} path - base Path
|
|
72066
|
+
* @param {Hono} app - other Hono instance
|
|
72067
|
+
* @returns {Hono} routed Hono instance
|
|
72068
|
+
*
|
|
72069
|
+
* @example
|
|
72070
|
+
* ```ts
|
|
72071
|
+
* const app = new Hono()
|
|
72072
|
+
* const app2 = new Hono()
|
|
72073
|
+
*
|
|
72074
|
+
* app2.get("/user", (c) => c.text("user"))
|
|
72075
|
+
* app.route("/api", app2) // GET /api/user
|
|
72076
|
+
* ```
|
|
72077
|
+
*/
|
|
72321
72078
|
route(path, app) {
|
|
72322
72079
|
const subApp = this.basePath(path);
|
|
72323
72080
|
app.routes.map((r5) => {
|
|
72324
72081
|
let handler2;
|
|
72325
|
-
if (app.errorHandler === errorHandler)
|
|
72326
|
-
|
|
72327
|
-
} else {
|
|
72082
|
+
if (app.errorHandler === errorHandler) handler2 = r5.handler;
|
|
72083
|
+
else {
|
|
72328
72084
|
handler2 = async (c5, next) => (await compose([], app.errorHandler)(c5, () => r5.handler(c5, next))).res;
|
|
72329
72085
|
handler2[COMPOSED_HANDLER] = r5.handler;
|
|
72330
72086
|
}
|
|
@@ -72333,107 +72089,103 @@ var Hono = class _Hono {
|
|
|
72333
72089
|
return this;
|
|
72334
72090
|
}
|
|
72335
72091
|
/**
|
|
72336
|
-
|
|
72337
|
-
|
|
72338
|
-
|
|
72339
|
-
|
|
72340
|
-
|
|
72341
|
-
|
|
72342
|
-
|
|
72343
|
-
|
|
72344
|
-
|
|
72345
|
-
|
|
72346
|
-
|
|
72347
|
-
|
|
72092
|
+
* `.basePath()` allows base paths to be specified.
|
|
72093
|
+
*
|
|
72094
|
+
* @see {@link https://hono.dev/docs/api/routing#base-path}
|
|
72095
|
+
*
|
|
72096
|
+
* @param {string} path - base Path
|
|
72097
|
+
* @returns {Hono} changed Hono instance
|
|
72098
|
+
*
|
|
72099
|
+
* @example
|
|
72100
|
+
* ```ts
|
|
72101
|
+
* const api = new Hono().basePath('/api')
|
|
72102
|
+
* ```
|
|
72103
|
+
*/
|
|
72348
72104
|
basePath(path) {
|
|
72349
72105
|
const subApp = this.#clone();
|
|
72350
72106
|
subApp._basePath = mergePath(this._basePath, path);
|
|
72351
72107
|
return subApp;
|
|
72352
72108
|
}
|
|
72353
72109
|
/**
|
|
72354
|
-
|
|
72355
|
-
|
|
72356
|
-
|
|
72357
|
-
|
|
72358
|
-
|
|
72359
|
-
|
|
72360
|
-
|
|
72361
|
-
|
|
72362
|
-
|
|
72363
|
-
|
|
72364
|
-
|
|
72365
|
-
|
|
72366
|
-
|
|
72367
|
-
|
|
72368
|
-
|
|
72110
|
+
* `.onError()` handles an error and returns a customized Response.
|
|
72111
|
+
*
|
|
72112
|
+
* @see {@link https://hono.dev/docs/api/hono#error-handling}
|
|
72113
|
+
*
|
|
72114
|
+
* @param {ErrorHandler} handler - request Handler for error
|
|
72115
|
+
* @returns {Hono} changed Hono instance
|
|
72116
|
+
*
|
|
72117
|
+
* @example
|
|
72118
|
+
* ```ts
|
|
72119
|
+
* app.onError((err, c) => {
|
|
72120
|
+
* console.error(`${err}`)
|
|
72121
|
+
* return c.text('Custom Error Message', 500)
|
|
72122
|
+
* })
|
|
72123
|
+
* ```
|
|
72124
|
+
*/
|
|
72369
72125
|
onError = (handler2) => {
|
|
72370
72126
|
this.errorHandler = handler2;
|
|
72371
72127
|
return this;
|
|
72372
72128
|
};
|
|
72373
72129
|
/**
|
|
72374
|
-
|
|
72375
|
-
|
|
72376
|
-
|
|
72377
|
-
|
|
72378
|
-
|
|
72379
|
-
|
|
72380
|
-
|
|
72381
|
-
|
|
72382
|
-
|
|
72383
|
-
|
|
72384
|
-
|
|
72385
|
-
|
|
72386
|
-
|
|
72387
|
-
|
|
72130
|
+
* `.notFound()` allows you to customize a Not Found Response.
|
|
72131
|
+
*
|
|
72132
|
+
* @see {@link https://hono.dev/docs/api/hono#not-found}
|
|
72133
|
+
*
|
|
72134
|
+
* @param {NotFoundHandler} handler - request handler for not-found
|
|
72135
|
+
* @returns {Hono} changed Hono instance
|
|
72136
|
+
*
|
|
72137
|
+
* @example
|
|
72138
|
+
* ```ts
|
|
72139
|
+
* app.notFound((c) => {
|
|
72140
|
+
* return c.text('Custom 404 Message', 404)
|
|
72141
|
+
* })
|
|
72142
|
+
* ```
|
|
72143
|
+
*/
|
|
72388
72144
|
notFound = (handler2) => {
|
|
72389
72145
|
this.#notFoundHandler = handler2;
|
|
72390
72146
|
return this;
|
|
72391
72147
|
};
|
|
72392
72148
|
/**
|
|
72393
|
-
|
|
72394
|
-
|
|
72395
|
-
|
|
72396
|
-
|
|
72397
|
-
|
|
72398
|
-
|
|
72399
|
-
|
|
72400
|
-
|
|
72401
|
-
|
|
72402
|
-
|
|
72403
|
-
|
|
72404
|
-
|
|
72405
|
-
|
|
72406
|
-
|
|
72407
|
-
|
|
72408
|
-
|
|
72409
|
-
|
|
72410
|
-
|
|
72411
|
-
|
|
72412
|
-
|
|
72413
|
-
|
|
72414
|
-
|
|
72415
|
-
|
|
72416
|
-
|
|
72417
|
-
|
|
72418
|
-
|
|
72419
|
-
|
|
72420
|
-
|
|
72421
|
-
|
|
72422
|
-
|
|
72423
|
-
|
|
72149
|
+
* `.mount()` allows you to mount applications built with other frameworks into your Hono application.
|
|
72150
|
+
*
|
|
72151
|
+
* @see {@link https://hono.dev/docs/api/hono#mount}
|
|
72152
|
+
*
|
|
72153
|
+
* @param {string} path - base Path
|
|
72154
|
+
* @param {Function} applicationHandler - other Request Handler
|
|
72155
|
+
* @param {MountOptions} [options] - options of `.mount()`
|
|
72156
|
+
* @returns {Hono} mounted Hono instance
|
|
72157
|
+
*
|
|
72158
|
+
* @example
|
|
72159
|
+
* ```ts
|
|
72160
|
+
* import { Router as IttyRouter } from 'itty-router'
|
|
72161
|
+
* import { Hono } from 'hono'
|
|
72162
|
+
* // Create itty-router application
|
|
72163
|
+
* const ittyRouter = IttyRouter()
|
|
72164
|
+
* // GET /itty-router/hello
|
|
72165
|
+
* ittyRouter.get('/hello', () => new Response('Hello from itty-router'))
|
|
72166
|
+
*
|
|
72167
|
+
* const app = new Hono()
|
|
72168
|
+
* app.mount('/itty-router', ittyRouter.handle)
|
|
72169
|
+
* ```
|
|
72170
|
+
*
|
|
72171
|
+
* @example
|
|
72172
|
+
* ```ts
|
|
72173
|
+
* const app = new Hono()
|
|
72174
|
+
* // Send the request to another application without modification.
|
|
72175
|
+
* app.mount('/app', anotherApp, {
|
|
72176
|
+
* replaceRequest: (req) => req,
|
|
72177
|
+
* })
|
|
72178
|
+
* ```
|
|
72179
|
+
*/
|
|
72424
72180
|
mount(path, applicationHandler, options) {
|
|
72425
72181
|
let replaceRequest;
|
|
72426
72182
|
let optionHandler;
|
|
72427
72183
|
if (options) {
|
|
72428
|
-
if (typeof options === "function")
|
|
72429
|
-
|
|
72430
|
-
} else {
|
|
72184
|
+
if (typeof options === "function") optionHandler = options;
|
|
72185
|
+
else {
|
|
72431
72186
|
optionHandler = options.optionHandler;
|
|
72432
|
-
if (options.replaceRequest === false)
|
|
72433
|
-
|
|
72434
|
-
} else {
|
|
72435
|
-
replaceRequest = options.replaceRequest;
|
|
72436
|
-
}
|
|
72187
|
+
if (options.replaceRequest === false) replaceRequest = (request) => request;
|
|
72188
|
+
else replaceRequest = options.replaceRequest;
|
|
72437
72189
|
}
|
|
72438
72190
|
}
|
|
72439
72191
|
const getOptions = optionHandler ? (c5) => {
|
|
@@ -72458,12 +72210,10 @@ var Hono = class _Hono {
|
|
|
72458
72210
|
})();
|
|
72459
72211
|
const handler2 = async (c5, next) => {
|
|
72460
72212
|
const res = await applicationHandler(replaceRequest(c5.req.raw), ...getOptions(c5));
|
|
72461
|
-
if (res)
|
|
72462
|
-
return res;
|
|
72463
|
-
}
|
|
72213
|
+
if (res) return res;
|
|
72464
72214
|
await next();
|
|
72465
72215
|
};
|
|
72466
|
-
this.#addRoute(
|
|
72216
|
+
this.#addRoute("ALL", mergePath(path, "*"), handler2);
|
|
72467
72217
|
return this;
|
|
72468
72218
|
}
|
|
72469
72219
|
#addRoute(method, path, handler2, baseRoutePath) {
|
|
@@ -72478,15 +72228,11 @@ var Hono = class _Hono {
|
|
|
72478
72228
|
this.routes.push(r5);
|
|
72479
72229
|
}
|
|
72480
72230
|
#handleError(err, c5) {
|
|
72481
|
-
if (err instanceof Error)
|
|
72482
|
-
return this.errorHandler(err, c5);
|
|
72483
|
-
}
|
|
72231
|
+
if (err instanceof Error) return this.errorHandler(err, c5);
|
|
72484
72232
|
throw err;
|
|
72485
72233
|
}
|
|
72486
72234
|
#dispatch(request, executionCtx, env2, method) {
|
|
72487
|
-
if (method === "HEAD")
|
|
72488
|
-
return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
|
|
72489
|
-
}
|
|
72235
|
+
if (method === "HEAD") return (async () => new Response(null, await this.#dispatch(request, executionCtx, env2, "GET")))();
|
|
72490
72236
|
const path = this.getPath(request, { env: env2 });
|
|
72491
72237
|
const matchResult = this.router.match(method, path);
|
|
72492
72238
|
const c5 = new Context(request, {
|
|
@@ -72505,19 +72251,13 @@ var Hono = class _Hono {
|
|
|
72505
72251
|
} catch (err) {
|
|
72506
72252
|
return this.#handleError(err, c5);
|
|
72507
72253
|
}
|
|
72508
|
-
return res instanceof Promise ? res.then(
|
|
72509
|
-
(resolved) => resolved || (c5.finalized ? c5.res : this.#notFoundHandler(c5))
|
|
72510
|
-
).catch((err) => this.#handleError(err, c5)) : res ?? this.#notFoundHandler(c5);
|
|
72254
|
+
return res instanceof Promise ? res.then((resolved) => resolved || (c5.finalized ? c5.res : this.#notFoundHandler(c5))).catch((err) => this.#handleError(err, c5)) : res ?? this.#notFoundHandler(c5);
|
|
72511
72255
|
}
|
|
72512
72256
|
const composed = compose(matchResult[0], this.errorHandler, this.#notFoundHandler);
|
|
72513
72257
|
return (async () => {
|
|
72514
72258
|
try {
|
|
72515
72259
|
const context = await composed(c5);
|
|
72516
|
-
if (!context.finalized)
|
|
72517
|
-
throw new Error(
|
|
72518
|
-
"Context is not finalized. Did you forget to return a Response object or `await next()`?"
|
|
72519
|
-
);
|
|
72520
|
-
}
|
|
72260
|
+
if (!context.finalized) throw new Error("Context is not finalized. Did you forget to return a Response object or `await next()`?");
|
|
72521
72261
|
return context.res;
|
|
72522
72262
|
} catch (err) {
|
|
72523
72263
|
return this.#handleError(err, c5);
|
|
@@ -72525,62 +72265,53 @@ var Hono = class _Hono {
|
|
|
72525
72265
|
})();
|
|
72526
72266
|
}
|
|
72527
72267
|
/**
|
|
72528
|
-
|
|
72529
|
-
|
|
72530
|
-
|
|
72531
|
-
|
|
72532
|
-
|
|
72533
|
-
|
|
72534
|
-
|
|
72535
|
-
|
|
72536
|
-
|
|
72537
|
-
|
|
72268
|
+
* `.fetch()` will be entry point of your app.
|
|
72269
|
+
*
|
|
72270
|
+
* @see {@link https://hono.dev/docs/api/hono#fetch}
|
|
72271
|
+
*
|
|
72272
|
+
* @param {Request} request - request Object of request
|
|
72273
|
+
* @param {Env} env - env Object
|
|
72274
|
+
* @param {ExecutionContext} executionCtx - context of execution
|
|
72275
|
+
* @returns {Response | Promise<Response>} response of request
|
|
72276
|
+
*
|
|
72277
|
+
*/
|
|
72538
72278
|
fetch = (request, ...rest) => {
|
|
72539
72279
|
return this.#dispatch(request, rest[1], rest[0], request.method);
|
|
72540
72280
|
};
|
|
72541
72281
|
/**
|
|
72542
|
-
|
|
72543
|
-
|
|
72544
|
-
|
|
72545
|
-
|
|
72546
|
-
|
|
72547
|
-
|
|
72548
|
-
|
|
72549
|
-
|
|
72550
|
-
|
|
72551
|
-
|
|
72552
|
-
|
|
72282
|
+
* `.request()` is a useful method for testing.
|
|
72283
|
+
* You can pass a URL or pathname to send a GET request.
|
|
72284
|
+
* app will return a Response object.
|
|
72285
|
+
* ```ts
|
|
72286
|
+
* test('GET /hello is ok', async () => {
|
|
72287
|
+
* const res = await app.request('/hello')
|
|
72288
|
+
* expect(res.status).toBe(200)
|
|
72289
|
+
* })
|
|
72290
|
+
* ```
|
|
72291
|
+
* @see https://hono.dev/docs/api/hono#request
|
|
72292
|
+
*/
|
|
72553
72293
|
request = (input2, requestInit, Env, executionCtx) => {
|
|
72554
|
-
if (input2 instanceof Request)
|
|
72555
|
-
return this.fetch(requestInit ? new Request(input2, requestInit) : input2, Env, executionCtx);
|
|
72556
|
-
}
|
|
72294
|
+
if (input2 instanceof Request) return this.fetch(requestInit ? new Request(input2, requestInit) : input2, Env, executionCtx);
|
|
72557
72295
|
input2 = input2.toString();
|
|
72558
|
-
return this.fetch(
|
|
72559
|
-
new Request(
|
|
72560
|
-
/^https?:\/\//.test(input2) ? input2 : `http://localhost${mergePath("/", input2)}`,
|
|
72561
|
-
requestInit
|
|
72562
|
-
),
|
|
72563
|
-
Env,
|
|
72564
|
-
executionCtx
|
|
72565
|
-
);
|
|
72296
|
+
return this.fetch(new Request(/^https?:\/\//.test(input2) ? input2 : `http://localhost${mergePath("/", input2)}`, requestInit), Env, executionCtx);
|
|
72566
72297
|
};
|
|
72567
72298
|
/**
|
|
72568
|
-
|
|
72569
|
-
|
|
72570
|
-
|
|
72571
|
-
|
|
72572
|
-
|
|
72573
|
-
|
|
72574
|
-
|
|
72575
|
-
|
|
72576
|
-
|
|
72577
|
-
|
|
72578
|
-
|
|
72579
|
-
|
|
72580
|
-
|
|
72581
|
-
|
|
72582
|
-
|
|
72583
|
-
|
|
72299
|
+
* `.fire()` automatically adds a global fetch event listener.
|
|
72300
|
+
* This can be useful for environments that adhere to the Service Worker API, such as non-ES module Cloudflare Workers.
|
|
72301
|
+
* @deprecated
|
|
72302
|
+
* Use `fire` from `hono/service-worker` instead.
|
|
72303
|
+
* ```ts
|
|
72304
|
+
* import { Hono } from 'hono'
|
|
72305
|
+
* import { fire } from 'hono/service-worker'
|
|
72306
|
+
*
|
|
72307
|
+
* const app = new Hono()
|
|
72308
|
+
* // ...
|
|
72309
|
+
* fire(app)
|
|
72310
|
+
* ```
|
|
72311
|
+
* @see https://hono.dev/docs/api/hono#fire
|
|
72312
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/API/Service_Worker_API
|
|
72313
|
+
* @see https://developers.cloudflare.com/workers/reference/migrate-to-module-workers/
|
|
72314
|
+
*/
|
|
72584
72315
|
fire = () => {
|
|
72585
72316
|
addEventListener("fetch", (event) => {
|
|
72586
72317
|
event.respondWith(this.#dispatch(event.request, event, void 0, event.request.method));
|
|
@@ -72596,15 +72327,11 @@ var emptyParam = [];
|
|
|
72596
72327
|
function match(method, path) {
|
|
72597
72328
|
const matchers = this.buildAllMatchers();
|
|
72598
72329
|
const match2 = ((method2, path2) => {
|
|
72599
|
-
const matcher = matchers[method2] || matchers[
|
|
72330
|
+
const matcher = matchers[method2] || matchers["ALL"];
|
|
72600
72331
|
const staticMatch = matcher[2][path2];
|
|
72601
|
-
if (staticMatch)
|
|
72602
|
-
return staticMatch;
|
|
72603
|
-
}
|
|
72332
|
+
if (staticMatch) return staticMatch;
|
|
72604
72333
|
const match3 = path2.match(matcher[0]);
|
|
72605
|
-
if (!match3)
|
|
72606
|
-
return [[], emptyParam];
|
|
72607
|
-
}
|
|
72334
|
+
if (!match3) return [[], emptyParam];
|
|
72608
72335
|
const index = match3.indexOf("", 1);
|
|
72609
72336
|
return [matcher[1][index], match3];
|
|
72610
72337
|
});
|
|
@@ -72614,31 +72341,19 @@ function match(method, path) {
|
|
|
72614
72341
|
|
|
72615
72342
|
// node_modules/hono/dist/router/reg-exp-router/node.js
|
|
72616
72343
|
var LABEL_REG_EXP_STR = "[^/]+";
|
|
72617
|
-
var ONLY_WILDCARD_REG_EXP_STR = ".*";
|
|
72618
72344
|
var TAIL_WILDCARD_REG_EXP_STR = "(?:|/.*)";
|
|
72619
72345
|
var PATH_ERROR = /* @__PURE__ */ Symbol();
|
|
72620
|
-
var regExpMetaChars = new Set(".\\+*[^]$()");
|
|
72346
|
+
var regExpMetaChars = /* @__PURE__ */ new Set(".\\+*[^]$()");
|
|
72621
72347
|
function compareKey(a5, b5) {
|
|
72622
|
-
if (a5.length === 1)
|
|
72623
|
-
|
|
72624
|
-
|
|
72625
|
-
if (b5
|
|
72626
|
-
|
|
72627
|
-
|
|
72628
|
-
if (a5 === ONLY_WILDCARD_REG_EXP_STR || a5 === TAIL_WILDCARD_REG_EXP_STR) {
|
|
72629
|
-
return b5 === TAIL_WILDCARD_REG_EXP_STR ? -1 : 1;
|
|
72630
|
-
} else if (b5 === ONLY_WILDCARD_REG_EXP_STR || b5 === TAIL_WILDCARD_REG_EXP_STR) {
|
|
72631
|
-
return -1;
|
|
72632
|
-
}
|
|
72633
|
-
if (a5 === LABEL_REG_EXP_STR) {
|
|
72634
|
-
return 1;
|
|
72635
|
-
} else if (b5 === LABEL_REG_EXP_STR) {
|
|
72636
|
-
return -1;
|
|
72637
|
-
}
|
|
72348
|
+
if (a5.length === 1) return b5.length === 1 ? a5 < b5 ? -1 : 1 : -1;
|
|
72349
|
+
if (b5.length === 1) return 1;
|
|
72350
|
+
if (a5 === ".*" || a5 === "(?:|/.*)") return b5 === "(?:|/.*)" ? -1 : 1;
|
|
72351
|
+
else if (b5 === ".*" || b5 === "(?:|/.*)") return -1;
|
|
72352
|
+
if (a5 === "[^/]+") return 1;
|
|
72353
|
+
else if (b5 === "[^/]+") return -1;
|
|
72638
72354
|
return a5.length === b5.length ? a5 < b5 ? -1 : 1 : b5.length - a5.length;
|
|
72639
72355
|
}
|
|
72640
|
-
var Node = class
|
|
72641
|
-
// handler index of a dynamic path, or -1 for a static path terminal
|
|
72356
|
+
var Node = class Node2 {
|
|
72642
72357
|
#index;
|
|
72643
72358
|
#varIndex;
|
|
72644
72359
|
#children = createNullObject();
|
|
@@ -72646,36 +72361,35 @@ var Node = class _Node {
|
|
|
72646
72361
|
let node2 = this;
|
|
72647
72362
|
for (let i5 = 0, len = tokens.length; i5 < len; i5++) {
|
|
72648
72363
|
const token = tokens[i5];
|
|
72649
|
-
const pattern = token.length === 1 ? token === "*" ? i5 === len - 1 ? [
|
|
72364
|
+
const pattern = token.length === 1 ? token === "*" ? i5 === len - 1 ? [
|
|
72365
|
+
"",
|
|
72366
|
+
"",
|
|
72367
|
+
".*"
|
|
72368
|
+
] : [
|
|
72369
|
+
"",
|
|
72370
|
+
"",
|
|
72371
|
+
LABEL_REG_EXP_STR
|
|
72372
|
+
] : null : token === "/*" ? [
|
|
72373
|
+
"",
|
|
72374
|
+
"",
|
|
72375
|
+
TAIL_WILDCARD_REG_EXP_STR
|
|
72376
|
+
] : token.match(/^\:([^\{\}]+)(?:\{(.+)\})?$/);
|
|
72650
72377
|
let nextNode;
|
|
72651
72378
|
if (pattern) {
|
|
72652
72379
|
const name = pattern[1];
|
|
72653
|
-
let regexpStr = pattern[2] ||
|
|
72380
|
+
let regexpStr = pattern[2] || "[^/]+";
|
|
72654
72381
|
if (name && pattern[2]) {
|
|
72655
|
-
if (regexpStr === ".*")
|
|
72656
|
-
throw PATH_ERROR;
|
|
72657
|
-
}
|
|
72382
|
+
if (regexpStr === ".*") throw PATH_ERROR;
|
|
72658
72383
|
regexpStr = regexpStr.replace(/^\((?!\?:)(?=[^)]+\)$)/, "(?:");
|
|
72659
|
-
if (/\((?!\?:)/.test(regexpStr))
|
|
72660
|
-
|
|
72661
|
-
}
|
|
72662
|
-
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) {
|
|
72663
|
-
throw PATH_ERROR;
|
|
72664
|
-
}
|
|
72384
|
+
if (/\((?!\?:)/.test(regexpStr)) throw PATH_ERROR;
|
|
72385
|
+
if (regexpStr.length === 1 && regExpMetaChars.has(regexpStr)) throw PATH_ERROR;
|
|
72665
72386
|
}
|
|
72666
72387
|
nextNode = node2.#children[regexpStr];
|
|
72667
72388
|
if (!nextNode) {
|
|
72668
|
-
if (regexpStr !==
|
|
72669
|
-
for (const k5 in node2.#children)
|
|
72670
|
-
if (
|
|
72671
|
-
// a single-char pattern coexists with single-char literals as a literal does
|
|
72672
|
-
(regexpStr.length > 1 || k5.length > 1) && k5 !== ONLY_WILDCARD_REG_EXP_STR && k5 !== TAIL_WILDCARD_REG_EXP_STR
|
|
72673
|
-
) {
|
|
72674
|
-
throw PATH_ERROR;
|
|
72675
|
-
}
|
|
72676
|
-
}
|
|
72389
|
+
if (regexpStr !== ".*" && regexpStr !== "(?:|/.*)") {
|
|
72390
|
+
for (const k5 in node2.#children) if ((regexpStr.length > 1 || k5.length > 1) && k5 !== ".*" && k5 !== "(?:|/.*)") throw PATH_ERROR;
|
|
72677
72391
|
}
|
|
72678
|
-
nextNode = node2.#children[regexpStr] = new
|
|
72392
|
+
nextNode = node2.#children[regexpStr] = new Node2();
|
|
72679
72393
|
}
|
|
72680
72394
|
if (name !== "") {
|
|
72681
72395
|
nextNode.#varIndex ??= context.varIndex++;
|
|
@@ -72684,37 +72398,24 @@ var Node = class _Node {
|
|
|
72684
72398
|
} else {
|
|
72685
72399
|
nextNode = node2.#children[token];
|
|
72686
72400
|
if (!nextNode) {
|
|
72687
|
-
for (const k5 in node2.#children)
|
|
72688
|
-
|
|
72689
|
-
throw PATH_ERROR;
|
|
72690
|
-
}
|
|
72691
|
-
}
|
|
72692
|
-
nextNode = node2.#children[token] = new _Node();
|
|
72401
|
+
for (const k5 in node2.#children) if (k5.length > 1 && k5 !== ".*" && k5 !== "(?:|/.*)") throw PATH_ERROR;
|
|
72402
|
+
nextNode = node2.#children[token] = new Node2();
|
|
72693
72403
|
}
|
|
72694
72404
|
}
|
|
72695
72405
|
node2 = nextNode;
|
|
72696
72406
|
}
|
|
72697
|
-
if (node2.#index !== void 0)
|
|
72698
|
-
throw PATH_ERROR;
|
|
72699
|
-
}
|
|
72407
|
+
if (node2.#index !== void 0) throw PATH_ERROR;
|
|
72700
72408
|
node2.#index = isStatic ? -1 : index;
|
|
72701
72409
|
}
|
|
72702
72410
|
buildRegExpStr() {
|
|
72703
|
-
const
|
|
72704
|
-
const strList = childKeys.map((k5) => {
|
|
72411
|
+
const strList = Object.keys(this.#children).sort(compareKey).map((k5) => {
|
|
72705
72412
|
const c5 = this.#children[k5];
|
|
72706
72413
|
const childStr = c5.buildRegExpStr();
|
|
72707
72414
|
return childStr === "" ? "" : (typeof c5.#varIndex === "number" ? `(${k5})@${c5.#varIndex}` : regExpMetaChars.has(k5) ? `\\${k5}` : k5) + childStr;
|
|
72708
72415
|
}).filter(Boolean);
|
|
72709
|
-
if (typeof this.#index === "number" && this.#index !== -1) {
|
|
72710
|
-
|
|
72711
|
-
|
|
72712
|
-
if (strList.length === 0) {
|
|
72713
|
-
return "";
|
|
72714
|
-
}
|
|
72715
|
-
if (strList.length === 1) {
|
|
72716
|
-
return strList[0];
|
|
72717
|
-
}
|
|
72416
|
+
if (typeof this.#index === "number" && this.#index !== -1) strList.unshift(`#${this.#index}`);
|
|
72417
|
+
if (strList.length === 0) return "";
|
|
72418
|
+
if (strList.length === 1) return strList[0];
|
|
72718
72419
|
return "(?:" + strList.join("|") + ")";
|
|
72719
72420
|
}
|
|
72720
72421
|
};
|
|
@@ -72724,7 +72425,6 @@ var Trie = class {
|
|
|
72724
72425
|
#context = { varIndex: 0 };
|
|
72725
72426
|
#root = new Node();
|
|
72726
72427
|
#index = 0;
|
|
72727
|
-
// dynamic path -> [handler index, param assoc]; static paths are not registered
|
|
72728
72428
|
paths = createNullObject();
|
|
72729
72429
|
insert(path, isStatic) {
|
|
72730
72430
|
if (isStatic) {
|
|
@@ -72743,18 +72443,14 @@ var Trie = class {
|
|
|
72743
72443
|
replaced = true;
|
|
72744
72444
|
return mark;
|
|
72745
72445
|
});
|
|
72746
|
-
if (!replaced)
|
|
72747
|
-
break;
|
|
72748
|
-
}
|
|
72446
|
+
if (!replaced) break;
|
|
72749
72447
|
}
|
|
72750
72448
|
const tokens = markedPath.match(/(?::[^\/]+)|(?:\/\*$)|./g) || [];
|
|
72751
72449
|
for (let i5 = groups.length - 1; i5 >= 0; i5--) {
|
|
72752
72450
|
const [mark] = groups[i5];
|
|
72753
|
-
for (let j5 = tokens.length - 1; j5 >= 0; j5--) {
|
|
72754
|
-
|
|
72755
|
-
|
|
72756
|
-
break;
|
|
72757
|
-
}
|
|
72451
|
+
for (let j5 = tokens.length - 1; j5 >= 0; j5--) if (tokens[j5].indexOf(mark) !== -1) {
|
|
72452
|
+
tokens[j5] = tokens[j5].replace(mark, groups[i5][1]);
|
|
72453
|
+
break;
|
|
72758
72454
|
}
|
|
72759
72455
|
}
|
|
72760
72456
|
this.#root.insert(tokens, this.#index, paramAssoc, this.#context, false);
|
|
@@ -72762,9 +72458,11 @@ var Trie = class {
|
|
|
72762
72458
|
}
|
|
72763
72459
|
buildRegExp() {
|
|
72764
72460
|
let regexp = this.#root.buildRegExpStr();
|
|
72765
|
-
if (regexp === "")
|
|
72766
|
-
|
|
72767
|
-
|
|
72461
|
+
if (regexp === "") return [
|
|
72462
|
+
/^$/,
|
|
72463
|
+
[],
|
|
72464
|
+
[]
|
|
72465
|
+
];
|
|
72768
72466
|
let captureIndex = 0;
|
|
72769
72467
|
const indexReplacementMap = [];
|
|
72770
72468
|
const paramReplacementMap = [];
|
|
@@ -72779,27 +72477,21 @@ var Trie = class {
|
|
|
72779
72477
|
}
|
|
72780
72478
|
return "";
|
|
72781
72479
|
});
|
|
72782
|
-
return [
|
|
72480
|
+
return [
|
|
72481
|
+
new RegExp(`^${regexp}`),
|
|
72482
|
+
indexReplacementMap,
|
|
72483
|
+
paramReplacementMap
|
|
72484
|
+
];
|
|
72783
72485
|
}
|
|
72784
72486
|
};
|
|
72785
72487
|
|
|
72786
72488
|
// node_modules/hono/dist/router/reg-exp-router/router.js
|
|
72787
72489
|
var wildcardRegExpCache = createNullObject();
|
|
72788
72490
|
function buildWildcardRegExp(path) {
|
|
72789
|
-
return wildcardRegExpCache[path] ??= new RegExp(
|
|
72790
|
-
`^${path.replace(
|
|
72791
|
-
/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g,
|
|
72792
|
-
(match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ONLY_WILDCARD_REG_EXP_STR : `/:${LABEL_REG_EXP_STR}`
|
|
72793
|
-
)}$`
|
|
72794
|
-
);
|
|
72491
|
+
return wildcardRegExpCache[path] ??= new RegExp(`^${path.replace(/\/:[^/{}]+(?:\{\[\^\/]\+})?(?=[/{]|$)|\/?\*$|([.\\+*[^\]$()?{}|])/g, (match2, metaChar) => metaChar ? `\\${metaChar}` : match2 === "/*" ? TAIL_WILDCARD_REG_EXP_STR : match2 === "*" ? ".*" : `/:${LABEL_REG_EXP_STR}`)}$`);
|
|
72795
72492
|
}
|
|
72796
72493
|
function findMiddleware(middleware, path) {
|
|
72797
|
-
for (const k5 of Object.keys(middleware).sort((a5, b5) => b5.length - a5.length))
|
|
72798
|
-
if (buildWildcardRegExp(k5).test(path)) {
|
|
72799
|
-
return [...middleware[k5]];
|
|
72800
|
-
}
|
|
72801
|
-
}
|
|
72802
|
-
return void 0;
|
|
72494
|
+
for (const k5 of Object.keys(middleware).sort((a5, b5) => b5.length - a5.length)) if (buildWildcardRegExp(k5).test(path)) return [...middleware[k5]];
|
|
72803
72495
|
}
|
|
72804
72496
|
var RegExpRouter = class {
|
|
72805
72497
|
name = "RegExpRouter";
|
|
@@ -72807,9 +72499,9 @@ var RegExpRouter = class {
|
|
|
72807
72499
|
#routes;
|
|
72808
72500
|
#tries;
|
|
72809
72501
|
constructor() {
|
|
72810
|
-
this.#middleware = { [
|
|
72811
|
-
this.#routes = { [
|
|
72812
|
-
this.#tries = { [
|
|
72502
|
+
this.#middleware = { ["ALL"]: createNullObject() };
|
|
72503
|
+
this.#routes = { ["ALL"]: createNullObject() };
|
|
72504
|
+
this.#tries = { ["ALL"]: new Trie() };
|
|
72813
72505
|
}
|
|
72814
72506
|
#insertPath(method, path) {
|
|
72815
72507
|
try {
|
|
@@ -72821,57 +72513,41 @@ var RegExpRouter = class {
|
|
|
72821
72513
|
add(method, path, handler2) {
|
|
72822
72514
|
const middleware = this.#middleware;
|
|
72823
72515
|
const routes = this.#routes;
|
|
72824
|
-
if (!middleware)
|
|
72825
|
-
throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
72826
|
-
}
|
|
72516
|
+
if (!middleware) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
72827
72517
|
if (!middleware[method]) {
|
|
72828
72518
|
this.#tries[method] = new Trie();
|
|
72829
72519
|
for (const handlerMap of [middleware, routes]) {
|
|
72830
72520
|
handlerMap[method] = createNullObject();
|
|
72831
|
-
for (const p3 in handlerMap[
|
|
72832
|
-
handlerMap[method][p3] = [...handlerMap[
|
|
72521
|
+
for (const p3 in handlerMap["ALL"]) {
|
|
72522
|
+
handlerMap[method][p3] = [...handlerMap["ALL"][p3]];
|
|
72833
72523
|
this.#insertPath(method, p3);
|
|
72834
72524
|
}
|
|
72835
72525
|
}
|
|
72836
72526
|
}
|
|
72837
|
-
if (path === "/*")
|
|
72838
|
-
|
|
72839
|
-
}
|
|
72840
|
-
const methods = method === METHOD_NAME_ALL ? Object.keys(middleware) : [method];
|
|
72527
|
+
if (path === "/*") path = "*";
|
|
72528
|
+
const methods = method === "ALL" ? Object.keys(middleware) : [method];
|
|
72841
72529
|
if (/\*$/.test(path)) {
|
|
72842
72530
|
const re = buildWildcardRegExp(path);
|
|
72843
|
-
for (const m3 of methods) {
|
|
72844
|
-
|
|
72845
|
-
|
|
72846
|
-
middleware[m3][path] = findMiddleware(middleware[m3], path) || findMiddleware(middleware[METHOD_NAME_ALL], path) || [];
|
|
72847
|
-
}
|
|
72848
|
-
}
|
|
72849
|
-
for (const handlerMap of [middleware, routes]) {
|
|
72850
|
-
for (const m3 of methods) {
|
|
72851
|
-
for (const p3 in handlerMap[m3]) {
|
|
72852
|
-
re.test(p3) && handlerMap[m3][p3].push([handler2, path]);
|
|
72853
|
-
}
|
|
72854
|
-
}
|
|
72531
|
+
for (const m3 of methods) if (!middleware[m3][path]) {
|
|
72532
|
+
this.#insertPath(m3, path);
|
|
72533
|
+
middleware[m3][path] = findMiddleware(middleware[m3], path) || findMiddleware(middleware["ALL"], path) || [];
|
|
72855
72534
|
}
|
|
72535
|
+
for (const handlerMap of [middleware, routes]) for (const m3 of methods) for (const p3 in handlerMap[m3]) re.test(p3) && handlerMap[m3][p3].push([handler2, path]);
|
|
72856
72536
|
return;
|
|
72857
72537
|
}
|
|
72858
72538
|
const paths = checkOptionalParameter(path) || [path];
|
|
72859
|
-
for (const path2 of paths) {
|
|
72860
|
-
|
|
72861
|
-
|
|
72862
|
-
|
|
72863
|
-
routes[m3][path2] = findMiddleware(middleware[m3], path2) || findMiddleware(middleware[METHOD_NAME_ALL], path2) || [];
|
|
72864
|
-
}
|
|
72865
|
-
routes[m3][path2].push([handler2, path2]);
|
|
72539
|
+
for (const path2 of paths) for (const m3 of methods) {
|
|
72540
|
+
if (!routes[m3][path2]) {
|
|
72541
|
+
this.#insertPath(m3, path2);
|
|
72542
|
+
routes[m3][path2] = findMiddleware(middleware[m3], path2) || findMiddleware(middleware["ALL"], path2) || [];
|
|
72866
72543
|
}
|
|
72544
|
+
routes[m3][path2].push([handler2, path2]);
|
|
72867
72545
|
}
|
|
72868
72546
|
}
|
|
72869
72547
|
match = match;
|
|
72870
72548
|
buildAllMatchers() {
|
|
72871
72549
|
const matchers = createNullObject();
|
|
72872
|
-
for (const method of Object.keys(this.#routes))
|
|
72873
|
-
matchers[method] = this.#buildMatcher(method);
|
|
72874
|
-
}
|
|
72550
|
+
for (const method of Object.keys(this.#routes)) matchers[method] = this.#buildMatcher(method);
|
|
72875
72551
|
this.#middleware = this.#routes = this.#tries = void 0;
|
|
72876
72552
|
wildcardRegExpCache = createNullObject();
|
|
72877
72553
|
return matchers;
|
|
@@ -72883,24 +72559,23 @@ var RegExpRouter = class {
|
|
|
72883
72559
|
const staticMap = createNullObject();
|
|
72884
72560
|
const handlerData = [];
|
|
72885
72561
|
const [regexp, indexReplacementMap, paramReplacementMap] = trie.buildRegExp();
|
|
72886
|
-
for (const r5 of [middleware, routes]) {
|
|
72887
|
-
|
|
72888
|
-
|
|
72889
|
-
|
|
72890
|
-
|
|
72891
|
-
|
|
72892
|
-
continue;
|
|
72893
|
-
}
|
|
72894
|
-
handlerData[pathData[0]] = handlers.map(([h5, handlerPath]) => [
|
|
72895
|
-
h5,
|
|
72896
|
-
trie.paths[handlerPath][1].reduceRight((map4, [key], i5) => {
|
|
72897
|
-
map4[key] = paramReplacementMap[pathData[1][i5][1]];
|
|
72898
|
-
return map4;
|
|
72899
|
-
}, createNullObject())
|
|
72900
|
-
]);
|
|
72562
|
+
for (const r5 of [middleware, routes]) for (const path in r5) {
|
|
72563
|
+
const handlers = r5[path];
|
|
72564
|
+
const pathData = trie.paths[path];
|
|
72565
|
+
if (!pathData) {
|
|
72566
|
+
staticMap[path] = [handlers.map(([h5]) => [h5, createNullObject()]), emptyParam];
|
|
72567
|
+
continue;
|
|
72901
72568
|
}
|
|
72569
|
+
handlerData[pathData[0]] = handlers.map(([h5, handlerPath]) => [h5, trie.paths[handlerPath][1].reduceRight((map4, [key], i5) => {
|
|
72570
|
+
map4[key] = paramReplacementMap[pathData[1][i5][1]];
|
|
72571
|
+
return map4;
|
|
72572
|
+
}, createNullObject())]);
|
|
72902
72573
|
}
|
|
72903
|
-
return [
|
|
72574
|
+
return [
|
|
72575
|
+
regexp,
|
|
72576
|
+
indexReplacementMap.map((i5) => handlerData[i5]),
|
|
72577
|
+
staticMap
|
|
72578
|
+
];
|
|
72904
72579
|
}
|
|
72905
72580
|
};
|
|
72906
72581
|
|
|
@@ -72913,15 +72588,15 @@ var SmartRouter = class {
|
|
|
72913
72588
|
this.#routers = init.routers;
|
|
72914
72589
|
}
|
|
72915
72590
|
add(method, path, handler2) {
|
|
72916
|
-
if (!this.#routes)
|
|
72917
|
-
|
|
72918
|
-
|
|
72919
|
-
|
|
72591
|
+
if (!this.#routes) throw new Error(MESSAGE_MATCHER_IS_ALREADY_BUILT);
|
|
72592
|
+
this.#routes.push([
|
|
72593
|
+
method,
|
|
72594
|
+
path,
|
|
72595
|
+
handler2
|
|
72596
|
+
]);
|
|
72920
72597
|
}
|
|
72921
72598
|
match(method, path) {
|
|
72922
|
-
if (!this.#routes)
|
|
72923
|
-
throw new Error("Fatal error");
|
|
72924
|
-
}
|
|
72599
|
+
if (!this.#routes) throw new Error("Fatal error");
|
|
72925
72600
|
const routers = this.#routers;
|
|
72926
72601
|
const routes = this.#routes;
|
|
72927
72602
|
const len = routers.length;
|
|
@@ -72930,14 +72605,10 @@ var SmartRouter = class {
|
|
|
72930
72605
|
for (; i5 < len; i5++) {
|
|
72931
72606
|
const router = routers[i5];
|
|
72932
72607
|
try {
|
|
72933
|
-
for (let
|
|
72934
|
-
router.add(...routes[i22]);
|
|
72935
|
-
}
|
|
72608
|
+
for (let i6 = 0, len2 = routes.length; i6 < len2; i6++) router.add(...routes[i6]);
|
|
72936
72609
|
res = router.match(method, path);
|
|
72937
72610
|
} catch (e5) {
|
|
72938
|
-
if (e5 instanceof UnsupportedPathError)
|
|
72939
|
-
continue;
|
|
72940
|
-
}
|
|
72611
|
+
if (e5 instanceof UnsupportedPathError) continue;
|
|
72941
72612
|
throw e5;
|
|
72942
72613
|
}
|
|
72943
72614
|
this.match = router.match.bind(router);
|
|
@@ -72945,16 +72616,12 @@ var SmartRouter = class {
|
|
|
72945
72616
|
this.#routes = void 0;
|
|
72946
72617
|
break;
|
|
72947
72618
|
}
|
|
72948
|
-
if (i5 === len)
|
|
72949
|
-
throw new Error("Fatal error");
|
|
72950
|
-
}
|
|
72619
|
+
if (i5 === len) throw new Error("Fatal error");
|
|
72951
72620
|
this.name = `SmartRouter + ${this.activeRouter.name}`;
|
|
72952
72621
|
return res;
|
|
72953
72622
|
}
|
|
72954
72623
|
get activeRouter() {
|
|
72955
|
-
if (this.#routes || this.#routers.length !== 1)
|
|
72956
|
-
throw new Error("No active router has been determined yet.");
|
|
72957
|
-
}
|
|
72624
|
+
if (this.#routes || this.#routers.length !== 1) throw new Error("No active router has been determined yet.");
|
|
72958
72625
|
return this.#routers[0];
|
|
72959
72626
|
}
|
|
72960
72627
|
};
|
|
@@ -72962,7 +72629,7 @@ var SmartRouter = class {
|
|
|
72962
72629
|
// node_modules/hono/dist/router/trie-router/node.js
|
|
72963
72630
|
var emptyParams = createNullObject();
|
|
72964
72631
|
var order = 0;
|
|
72965
|
-
var
|
|
72632
|
+
var Node3 = class Node4 {
|
|
72966
72633
|
#methods = [];
|
|
72967
72634
|
#children = createNullObject();
|
|
72968
72635
|
#patterns = [];
|
|
@@ -72978,34 +72645,30 @@ var Node2 = class _Node2 {
|
|
|
72978
72645
|
const pattern = getPattern(p3, nextP) || (nextP === void 0 && p3 && p3.indexOf("*") === p3.length - 1 ? p3 : null);
|
|
72979
72646
|
const isParam = Array.isArray(pattern);
|
|
72980
72647
|
const key = isParam ? pattern[0] : pattern || p3;
|
|
72981
|
-
const child = curNode.#children[key] ||= new
|
|
72648
|
+
const child = curNode.#children[key] ||= new Node4();
|
|
72982
72649
|
if (pattern && !child.#pattern) {
|
|
72983
72650
|
child.#pattern = pattern;
|
|
72984
72651
|
curNode.#patterns.push(child);
|
|
72985
72652
|
}
|
|
72986
72653
|
curNode = child;
|
|
72987
|
-
if (isParam)
|
|
72988
|
-
possibleKeys.add(pattern[1]);
|
|
72989
|
-
}
|
|
72654
|
+
if (isParam) possibleKeys.add(pattern[1]);
|
|
72990
72655
|
}
|
|
72991
|
-
curNode.#methods.push({
|
|
72992
|
-
|
|
72993
|
-
|
|
72994
|
-
|
|
72995
|
-
|
|
72996
|
-
}
|
|
72997
|
-
});
|
|
72656
|
+
curNode.#methods.push({ [method]: {
|
|
72657
|
+
handler: handler2,
|
|
72658
|
+
possibleKeys: [...possibleKeys],
|
|
72659
|
+
score: ++order
|
|
72660
|
+
} });
|
|
72998
72661
|
}
|
|
72999
72662
|
#pushHandlerSets(handlerSets, node2, method, nodeParams, params) {
|
|
73000
72663
|
for (let i5 = 0, len = node2.#methods.length; i5 < len; i5++) {
|
|
73001
72664
|
const m3 = node2.#methods[i5];
|
|
73002
|
-
const handlerSet = m3[method] || m3[
|
|
72665
|
+
const handlerSet = m3[method] || m3["ALL"];
|
|
73003
72666
|
if (handlerSet) {
|
|
73004
72667
|
handlerSet.params = createNullObject();
|
|
73005
72668
|
handlerSets.push(handlerSet);
|
|
73006
|
-
for (let
|
|
73007
|
-
const key = handlerSet.possibleKeys[
|
|
73008
|
-
handlerSet.params[key] = params?.[key] && !
|
|
72669
|
+
for (let i6 = 0, len2 = handlerSet.possibleKeys.length; i6 < len2; i6++) {
|
|
72670
|
+
const key = handlerSet.possibleKeys[i6];
|
|
72671
|
+
handlerSet.params[key] = params?.[key] && !i6 ? params[key] : nodeParams[key] ?? params?.[key];
|
|
73009
72672
|
}
|
|
73010
72673
|
}
|
|
73011
72674
|
}
|
|
@@ -73013,8 +72676,7 @@ var Node2 = class _Node2 {
|
|
|
73013
72676
|
search(method, path) {
|
|
73014
72677
|
const handlerSets = [];
|
|
73015
72678
|
this.#params = emptyParams;
|
|
73016
|
-
|
|
73017
|
-
let curNodes = [curNode];
|
|
72679
|
+
let curNodes = [this];
|
|
73018
72680
|
const parts = splitPath(path);
|
|
73019
72681
|
const curNodesQueue = [];
|
|
73020
72682
|
const len = parts.length;
|
|
@@ -73029,13 +72691,9 @@ var Node2 = class _Node2 {
|
|
|
73029
72691
|
if (nextNode) {
|
|
73030
72692
|
nextNode.#params = node2.#params;
|
|
73031
72693
|
if (isLast) {
|
|
73032
|
-
if (nextNode.#children["*"])
|
|
73033
|
-
this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node2.#params);
|
|
73034
|
-
}
|
|
72694
|
+
if (nextNode.#children["*"]) this.#pushHandlerSets(handlerSets, nextNode.#children["*"], method, node2.#params);
|
|
73035
72695
|
this.#pushHandlerSets(handlerSets, nextNode, method, node2.#params);
|
|
73036
|
-
} else
|
|
73037
|
-
tempNodes.push(nextNode);
|
|
73038
|
-
}
|
|
72696
|
+
} else tempNodes.push(nextNode);
|
|
73039
72697
|
}
|
|
73040
72698
|
for (const child of node2.#patterns) {
|
|
73041
72699
|
const pattern = child.#pattern;
|
|
@@ -73051,9 +72709,7 @@ var Node2 = class _Node2 {
|
|
|
73051
72709
|
continue;
|
|
73052
72710
|
}
|
|
73053
72711
|
const [, name, matcher] = pattern;
|
|
73054
|
-
if (!part && matcher === true)
|
|
73055
|
-
continue;
|
|
73056
|
-
}
|
|
72712
|
+
if (!part && matcher === true) continue;
|
|
73057
72713
|
if (matcher !== true) {
|
|
73058
72714
|
if (!partOffsets) {
|
|
73059
72715
|
partOffsets = [];
|
|
@@ -73068,20 +72724,11 @@ var Node2 = class _Node2 {
|
|
|
73068
72724
|
if (m3) {
|
|
73069
72725
|
params[name] = m3[0];
|
|
73070
72726
|
this.#pushHandlerSets(handlerSets, child, method, node2.#params, params);
|
|
73071
|
-
if (m3[0].length === restPathString.length && child.#children["*"])
|
|
73072
|
-
this.#pushHandlerSets(
|
|
73073
|
-
handlerSets,
|
|
73074
|
-
child.#children["*"],
|
|
73075
|
-
method,
|
|
73076
|
-
node2.#params,
|
|
73077
|
-
params
|
|
73078
|
-
);
|
|
73079
|
-
}
|
|
72727
|
+
if (m3[0].length === restPathString.length && child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, node2.#params, params);
|
|
73080
72728
|
for (const _ in child.#children) {
|
|
73081
72729
|
child.#params = params;
|
|
73082
72730
|
const componentCount = m3[0].match(/\//g)?.length ?? 0;
|
|
73083
|
-
|
|
73084
|
-
targetCurNodes.push(child);
|
|
72731
|
+
(curNodesQueue[componentCount] ||= []).push(child);
|
|
73085
72732
|
break;
|
|
73086
72733
|
}
|
|
73087
72734
|
continue;
|
|
@@ -73091,15 +72738,7 @@ var Node2 = class _Node2 {
|
|
|
73091
72738
|
params[name] = part;
|
|
73092
72739
|
if (isLast) {
|
|
73093
72740
|
this.#pushHandlerSets(handlerSets, child, method, params, node2.#params);
|
|
73094
|
-
if (child.#children["*"])
|
|
73095
|
-
this.#pushHandlerSets(
|
|
73096
|
-
handlerSets,
|
|
73097
|
-
child.#children["*"],
|
|
73098
|
-
method,
|
|
73099
|
-
params,
|
|
73100
|
-
node2.#params
|
|
73101
|
-
);
|
|
73102
|
-
}
|
|
72741
|
+
if (child.#children["*"]) this.#pushHandlerSets(handlerSets, child.#children["*"], method, params, node2.#params);
|
|
73103
72742
|
} else {
|
|
73104
72743
|
child.#params = params;
|
|
73105
72744
|
tempNodes.push(child);
|
|
@@ -73110,11 +72749,9 @@ var Node2 = class _Node2 {
|
|
|
73110
72749
|
const shifted = curNodesQueue.shift();
|
|
73111
72750
|
curNodes = shifted ? tempNodes.concat(shifted) : tempNodes;
|
|
73112
72751
|
}
|
|
73113
|
-
if (handlerSets[1]) {
|
|
73114
|
-
|
|
73115
|
-
|
|
73116
|
-
});
|
|
73117
|
-
}
|
|
72752
|
+
if (handlerSets[1]) handlerSets.sort((a5, b5) => {
|
|
72753
|
+
return a5.score - b5.score;
|
|
72754
|
+
});
|
|
73118
72755
|
return [handlerSets.map(({ handler: handler2, params }) => [handler2, params])];
|
|
73119
72756
|
}
|
|
73120
72757
|
};
|
|
@@ -73122,11 +72759,9 @@ var Node2 = class _Node2 {
|
|
|
73122
72759
|
// node_modules/hono/dist/router/trie-router/router.js
|
|
73123
72760
|
var TrieRouter = class {
|
|
73124
72761
|
name = "TrieRouter";
|
|
73125
|
-
#node = new
|
|
72762
|
+
#node = new Node3();
|
|
73126
72763
|
add(method, path, handler2) {
|
|
73127
|
-
for (const result of checkOptionalParameter(path) || [path])
|
|
73128
|
-
this.#node.insert(method, result, handler2);
|
|
73129
|
-
}
|
|
72764
|
+
for (const result of checkOptionalParameter(path) || [path]) this.#node.insert(method, result, handler2);
|
|
73130
72765
|
}
|
|
73131
72766
|
match(method, path) {
|
|
73132
72767
|
return this.#node.search(method, path);
|
|
@@ -73134,17 +72769,15 @@ var TrieRouter = class {
|
|
|
73134
72769
|
};
|
|
73135
72770
|
|
|
73136
72771
|
// node_modules/hono/dist/hono.js
|
|
73137
|
-
var
|
|
72772
|
+
var Hono3 = class extends Hono {
|
|
73138
72773
|
/**
|
|
73139
|
-
|
|
73140
|
-
|
|
73141
|
-
|
|
73142
|
-
|
|
72774
|
+
* Creates an instance of the Hono class.
|
|
72775
|
+
*
|
|
72776
|
+
* @param options - Optional configuration options for the Hono instance.
|
|
72777
|
+
*/
|
|
73143
72778
|
constructor(options = {}) {
|
|
73144
72779
|
super(options);
|
|
73145
|
-
this.router = options.router ?? new SmartRouter({
|
|
73146
|
-
routers: [new RegExpRouter(), new TrieRouter()]
|
|
73147
|
-
});
|
|
72780
|
+
this.router = options.router ?? new SmartRouter({ routers: [new RegExpRouter(), new TrieRouter()] });
|
|
73148
72781
|
}
|
|
73149
72782
|
};
|
|
73150
72783
|
|
|
@@ -74099,7 +73732,7 @@ function serializeForScriptTag(value) {
|
|
|
74099
73732
|
// packages/server/src/app.ts
|
|
74100
73733
|
function createApp(deps) {
|
|
74101
73734
|
const { config: config2 } = deps;
|
|
74102
|
-
const app = new
|
|
73735
|
+
const app = new Hono3();
|
|
74103
73736
|
const templates = new TemplateCache(deps.fetcher ?? globalThis.fetch);
|
|
74104
73737
|
const selectedBoard = config2.board ?? Object.keys(deps.boardConfig?.boards ?? {})[0] ?? "ze-great-team";
|
|
74105
73738
|
const allowlist = deps.allowlist ?? (deps.boardConfig ? deriveAllowlist(deps.boardConfig) : /* @__PURE__ */ new Map());
|
|
@@ -74484,7 +74117,7 @@ function safeDownloadFilename(value) {
|
|
|
74484
74117
|
|
|
74485
74118
|
// packages/server/src/blocked-app.ts
|
|
74486
74119
|
function createBlockedApp() {
|
|
74487
|
-
const app = new
|
|
74120
|
+
const app = new Hono3();
|
|
74488
74121
|
app.get("/health", (c5) => c5.json({ status: "ok" }));
|
|
74489
74122
|
app.all(
|
|
74490
74123
|
"/api/*",
|