raiton 6.1.1-beta.5 → 6.3.1-beta.11
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/CHANGELOG.md +30 -0
- package/build/bin/index.mjs +25 -1183
- package/docs/contributors/README.md +8 -1
- package/package.json +2 -2
- package/scripts/postinstall.ts +42 -0
- package/scripts/update-version.ts +532 -123
- package/source/core/injection/injection.ts +1 -1
- package/source/core/router/matcher.ts +16 -4
- package/source/framework/env.ts +4 -4
package/build/bin/index.mjs
CHANGED
|
@@ -21,12 +21,14 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
21
21
|
}
|
|
22
22
|
target = mod != null ? __create(__getProtoOf(mod)) : {};
|
|
23
23
|
const to = isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target;
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
if (mod && typeof mod === "object" || typeof mod === "function") {
|
|
25
|
+
for (let key of __getOwnPropNames(mod))
|
|
26
|
+
if (!__hasOwnProp.call(to, key))
|
|
27
|
+
__defProp(to, key, {
|
|
28
|
+
get: __accessProp.bind(mod, key),
|
|
29
|
+
enumerable: true
|
|
30
|
+
});
|
|
31
|
+
}
|
|
30
32
|
if (canCache)
|
|
31
33
|
cache.set(mod, to);
|
|
32
34
|
return to;
|
|
@@ -35,7 +37,7 @@ var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports,
|
|
|
35
37
|
var __require = /* @__PURE__ */ createRequire(import.meta.url);
|
|
36
38
|
|
|
37
39
|
// node_modules/reflect-metadata/Reflect.js
|
|
38
|
-
var require_Reflect = __commonJS(()
|
|
40
|
+
var require_Reflect = __commonJS(function() {
|
|
39
41
|
/*! *****************************************************************************
|
|
40
42
|
Copyright (C) Microsoft. All rights reserved.
|
|
41
43
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -1031,7 +1033,7 @@ var require_Reflect = __commonJS(() => {
|
|
|
1031
1033
|
});
|
|
1032
1034
|
|
|
1033
1035
|
// node_modules/commander/lib/error.js
|
|
1034
|
-
var require_error = __commonJS((exports)
|
|
1036
|
+
var require_error = __commonJS(function(exports) {
|
|
1035
1037
|
class CommanderError extends Error {
|
|
1036
1038
|
constructor(exitCode, code, message) {
|
|
1037
1039
|
super(message);
|
|
@@ -1055,7 +1057,7 @@ var require_error = __commonJS((exports) => {
|
|
|
1055
1057
|
});
|
|
1056
1058
|
|
|
1057
1059
|
// node_modules/commander/lib/argument.js
|
|
1058
|
-
var require_argument = __commonJS((exports)
|
|
1060
|
+
var require_argument = __commonJS(function(exports) {
|
|
1059
1061
|
var { InvalidArgumentError } = require_error();
|
|
1060
1062
|
|
|
1061
1063
|
class Argument {
|
|
@@ -1135,7 +1137,7 @@ var require_argument = __commonJS((exports) => {
|
|
|
1135
1137
|
});
|
|
1136
1138
|
|
|
1137
1139
|
// node_modules/commander/lib/help.js
|
|
1138
|
-
var require_help = __commonJS((exports)
|
|
1140
|
+
var require_help = __commonJS(function(exports) {
|
|
1139
1141
|
var { humanReadableArgName } = require_argument();
|
|
1140
1142
|
|
|
1141
1143
|
class Help {
|
|
@@ -1492,7 +1494,7 @@ ${itemIndentStr}`);
|
|
|
1492
1494
|
});
|
|
1493
1495
|
|
|
1494
1496
|
// node_modules/commander/lib/option.js
|
|
1495
|
-
var require_option = __commonJS((exports)
|
|
1497
|
+
var require_option = __commonJS(function(exports) {
|
|
1496
1498
|
var { InvalidArgumentError } = require_error();
|
|
1497
1499
|
|
|
1498
1500
|
class Option {
|
|
@@ -1676,7 +1678,7 @@ var require_option = __commonJS((exports) => {
|
|
|
1676
1678
|
});
|
|
1677
1679
|
|
|
1678
1680
|
// node_modules/commander/lib/suggestSimilar.js
|
|
1679
|
-
var require_suggestSimilar = __commonJS((exports)
|
|
1681
|
+
var require_suggestSimilar = __commonJS(function(exports) {
|
|
1680
1682
|
var maxDistance = 3;
|
|
1681
1683
|
function editDistance(a, b) {
|
|
1682
1684
|
if (Math.abs(a.length - b.length) > maxDistance)
|
|
@@ -1749,7 +1751,7 @@ var require_suggestSimilar = __commonJS((exports) => {
|
|
|
1749
1751
|
});
|
|
1750
1752
|
|
|
1751
1753
|
// node_modules/commander/lib/command.js
|
|
1752
|
-
var require_command = __commonJS((exports)
|
|
1754
|
+
var require_command = __commonJS(function(exports) {
|
|
1753
1755
|
var EventEmitter = __require("node:events").EventEmitter;
|
|
1754
1756
|
var childProcess = __require("node:child_process");
|
|
1755
1757
|
var path = __require("node:path");
|
|
@@ -3104,7 +3106,7 @@ Expecting one of '${allowedValues.join("', '")}'`);
|
|
|
3104
3106
|
});
|
|
3105
3107
|
|
|
3106
3108
|
// node_modules/commander/index.js
|
|
3107
|
-
var require_commander = __commonJS((exports)
|
|
3109
|
+
var require_commander = __commonJS(function(exports) {
|
|
3108
3110
|
var { Argument } = require_argument();
|
|
3109
3111
|
var { Command } = require_command();
|
|
3110
3112
|
var { CommanderError, InvalidArgumentError } = require_error();
|
|
@@ -3124,7 +3126,7 @@ var require_commander = __commonJS((exports) => {
|
|
|
3124
3126
|
});
|
|
3125
3127
|
|
|
3126
3128
|
// node_modules/reflect-metadata/Reflect.js
|
|
3127
|
-
var require_Reflect2 = __commonJS(()
|
|
3129
|
+
var require_Reflect2 = __commonJS(function() {
|
|
3128
3130
|
/*! *****************************************************************************
|
|
3129
3131
|
Copyright (C) Microsoft. All rights reserved.
|
|
3130
3132
|
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
@@ -4120,7 +4122,7 @@ var require_Reflect2 = __commonJS(() => {
|
|
|
4120
4122
|
});
|
|
4121
4123
|
|
|
4122
4124
|
// node_modules/@phc/format/index.js
|
|
4123
|
-
var require_format = __commonJS((exports, module)
|
|
4125
|
+
var require_format = __commonJS(function(exports, module) {
|
|
4124
4126
|
var idRegex = /^[a-z0-9-]{1,32}$/;
|
|
4125
4127
|
var nameRegex = /^[a-z0-9-]{1,32}$/;
|
|
4126
4128
|
var valueRegex = /^[a-zA-Z0-9/+.-]+$/;
|
|
@@ -4277,7 +4279,7 @@ var require_format = __commonJS((exports, module) => {
|
|
|
4277
4279
|
});
|
|
4278
4280
|
|
|
4279
4281
|
// node_modules/node-gyp-build/node-gyp-build.js
|
|
4280
|
-
var require_node_gyp_build = __commonJS((exports, module)
|
|
4282
|
+
var require_node_gyp_build = __commonJS(function(exports, module) {
|
|
4281
4283
|
var fs2 = __require("fs");
|
|
4282
4284
|
var path3 = __require("path");
|
|
4283
4285
|
var os = __require("os");
|
|
@@ -4466,7 +4468,7 @@ var require_node_gyp_build = __commonJS((exports, module) => {
|
|
|
4466
4468
|
});
|
|
4467
4469
|
|
|
4468
4470
|
// node_modules/node-gyp-build/index.js
|
|
4469
|
-
var require_node_gyp_build2 = __commonJS((exports, module)
|
|
4471
|
+
var require_node_gyp_build2 = __commonJS(function(exports, module) {
|
|
4470
4472
|
var runtimeRequire = typeof __webpack_require__ === "function" ? __non_webpack_require__ : __require;
|
|
4471
4473
|
if (typeof runtimeRequire.addon === "function") {
|
|
4472
4474
|
module.exports = runtimeRequire.addon.bind(runtimeRequire);
|
|
@@ -4476,7 +4478,7 @@ var require_node_gyp_build2 = __commonJS((exports, module) => {
|
|
|
4476
4478
|
});
|
|
4477
4479
|
|
|
4478
4480
|
// node_modules/argon2/argon2.cjs
|
|
4479
|
-
var require_argon2 = __commonJS((exports, module)
|
|
4481
|
+
var require_argon2 = __commonJS(function(exports, module) {
|
|
4480
4482
|
var __dirname = "/home/runner/work/raiton/raiton/node_modules/argon2";
|
|
4481
4483
|
var { randomBytes, timingSafeEqual } = __require("node:crypto");
|
|
4482
4484
|
var { promisify } = __require("node:util");
|
|
@@ -4594,7 +4596,7 @@ var require_argon2 = __commonJS((exports, module) => {
|
|
|
4594
4596
|
});
|
|
4595
4597
|
|
|
4596
4598
|
// node_modules/bcrypt/promises.js
|
|
4597
|
-
var require_promises = __commonJS((exports, module)
|
|
4599
|
+
var require_promises = __commonJS(function(exports, module) {
|
|
4598
4600
|
var Promise2 = global.Promise;
|
|
4599
4601
|
function promise(fn, context, args) {
|
|
4600
4602
|
if (!Array.isArray(args)) {
|
|
@@ -4628,7 +4630,7 @@ var require_promises = __commonJS((exports, module) => {
|
|
|
4628
4630
|
});
|
|
4629
4631
|
|
|
4630
4632
|
// node_modules/bcrypt/bcrypt.js
|
|
4631
|
-
var require_bcrypt = __commonJS((exports, module)
|
|
4633
|
+
var require_bcrypt = __commonJS(function(exports, module) {
|
|
4632
4634
|
var __dirname = "/home/runner/work/raiton/raiton/node_modules/bcrypt";
|
|
4633
4635
|
var path3 = __require("path");
|
|
4634
4636
|
var bindings = require_node_gyp_build2()(path3.resolve(__dirname));
|
|
@@ -4817,7 +4819,7 @@ var {
|
|
|
4817
4819
|
Help
|
|
4818
4820
|
} = import__.default;
|
|
4819
4821
|
// package.json
|
|
4820
|
-
var version = "6.
|
|
4822
|
+
var version = "6.3.1-beta.11";
|
|
4821
4823
|
|
|
4822
4824
|
// source/bin/cli.ts
|
|
4823
4825
|
var CLI = new Command;
|
|
@@ -5427,304 +5429,11 @@ var Environment;
|
|
|
5427
5429
|
Environment2.iOS = Platform === "iOS" || globalThis.navigator?.platform === "MacIntel" && globalThis.navigator?.maxTouchPoints > 1 || /iPad|iPhone|iPod/.test(globalThis.navigator?.platform);
|
|
5428
5430
|
Environment2.Android = Platform === "Android" || globalThis.navigator?.platform === "Android" || globalThis.navigator?.userAgent?.includes(" Android ") || globalThis.process?.platform === "android";
|
|
5429
5431
|
})(Environment || (Environment = {}));
|
|
5430
|
-
var EventDispatcher = class {
|
|
5431
|
-
propagations = {};
|
|
5432
|
-
entries = {};
|
|
5433
|
-
listen(type, callback, force) {
|
|
5434
|
-
this.entries[type] = this.entries[type] || [];
|
|
5435
|
-
this.entries[type].push({ callback, force });
|
|
5436
|
-
this.propagations[type] = false;
|
|
5437
|
-
return this;
|
|
5438
|
-
}
|
|
5439
|
-
dispatch(type, data) {
|
|
5440
|
-
if (this.entries[type]) {
|
|
5441
|
-
this.entries[type].map((entry) => {
|
|
5442
|
-
if (this.propagations[type] === true) {
|
|
5443
|
-
return;
|
|
5444
|
-
}
|
|
5445
|
-
const stop = entry.callback(data);
|
|
5446
|
-
if (stop === true) {
|
|
5447
|
-
this.propagations[type] = true;
|
|
5448
|
-
}
|
|
5449
|
-
});
|
|
5450
|
-
this.propagations[type] = false;
|
|
5451
|
-
}
|
|
5452
|
-
return this;
|
|
5453
|
-
}
|
|
5454
|
-
};
|
|
5455
5432
|
var paramsObject = UrlUtility.paramsObject;
|
|
5456
5433
|
var update = ObjectUtility.update;
|
|
5457
5434
|
var ascendingPath = HtmlUtility.ascendingPath;
|
|
5458
5435
|
var urlParams = UrlUtility.urlParams;
|
|
5459
|
-
var Navigation = class {
|
|
5460
|
-
options = {};
|
|
5461
|
-
emitter = new EventDispatcher;
|
|
5462
|
-
#oldRoute;
|
|
5463
|
-
constructor() {
|
|
5464
|
-
this.options.middlewares = this.options.middlewares || [];
|
|
5465
|
-
}
|
|
5466
|
-
currentRouteName() {
|
|
5467
|
-
return (this.options.useHashtagParser ? (location.hash || "").split("?")[0] : location.pathname).substring(1);
|
|
5468
|
-
}
|
|
5469
|
-
oldRouteName() {
|
|
5470
|
-
return this.#oldRoute;
|
|
5471
|
-
}
|
|
5472
|
-
currentQuery() {
|
|
5473
|
-
if (this.options.useHashtagParser) {
|
|
5474
|
-
return paramsObject((location.hash || location.search || "").split("?")[1] || "");
|
|
5475
|
-
} else {
|
|
5476
|
-
return paramsObject(location.search);
|
|
5477
|
-
}
|
|
5478
|
-
}
|
|
5479
|
-
setOption(optionName, value) {
|
|
5480
|
-
this.options[optionName] = value;
|
|
5481
|
-
return this;
|
|
5482
|
-
}
|
|
5483
|
-
setOptions(options) {
|
|
5484
|
-
this.options = update(this.options, options);
|
|
5485
|
-
this.emitter.dispatch("options", this);
|
|
5486
|
-
return this;
|
|
5487
|
-
}
|
|
5488
|
-
middleware(middleware) {
|
|
5489
|
-
this.options.middlewares?.push(middleware);
|
|
5490
|
-
return this;
|
|
5491
|
-
}
|
|
5492
|
-
observe() {
|
|
5493
|
-
window.addEventListener("popstate", (ev) => this.dispatchNavigate(ev));
|
|
5494
|
-
this.capturesActions();
|
|
5495
|
-
return this;
|
|
5496
|
-
}
|
|
5497
|
-
capturesActions() {
|
|
5498
|
-
if (this.options.capture) {
|
|
5499
|
-
document.body.addEventListener("click", (ev) => {
|
|
5500
|
-
const target = this.parseElementCaptured(ev);
|
|
5501
|
-
if (target && !target.hasAttribute("navigate:no-detection")) {
|
|
5502
|
-
const url = target.getAttribute("href") || target.getAttribute("navigate:view") || target.getAttribute("navigate-view");
|
|
5503
|
-
const blank = (target.getAttribute("target") || "").toLowerCase() == "_blank";
|
|
5504
|
-
const external = url ? this.isExternalURL(url) : false;
|
|
5505
|
-
if (url && !blank && !external) {
|
|
5506
|
-
ev.preventDefault();
|
|
5507
|
-
this.navigate(this.parseRouteName(url), {}, ev);
|
|
5508
|
-
}
|
|
5509
|
-
}
|
|
5510
|
-
}, false);
|
|
5511
|
-
}
|
|
5512
|
-
return this;
|
|
5513
|
-
}
|
|
5514
|
-
parseRouteName(routeName) {
|
|
5515
|
-
const route = routeName.trim();
|
|
5516
|
-
const firstChar = route.substring(0, 1);
|
|
5517
|
-
return firstChar == "/" || firstChar == "#" ? route.substring(1) : route;
|
|
5518
|
-
}
|
|
5519
|
-
isExternalURL(url) {
|
|
5520
|
-
return !!(url.match(/^http/gi) || url.match(/^\/\//gi));
|
|
5521
|
-
}
|
|
5522
|
-
parseElementCaptured(ev) {
|
|
5523
|
-
if (ev.target instanceof HTMLElement) {
|
|
5524
|
-
if (ev.target.hasAttribute("navigate:view") || ev.target.tagName == "A") {
|
|
5525
|
-
return ev.target;
|
|
5526
|
-
} else {
|
|
5527
|
-
return ascendingPath(ev.target, (parent) => parent.tagName == "A" || parent.hasAttribute("navigate:view"));
|
|
5528
|
-
}
|
|
5529
|
-
}
|
|
5530
|
-
return;
|
|
5531
|
-
}
|
|
5532
|
-
dispatchNavigate(ev) {
|
|
5533
|
-
const routeName = this.currentRouteName();
|
|
5534
|
-
const parser = this.options.useHashtagParser ? "hashtag" : "directory";
|
|
5535
|
-
this.options.middlewares?.forEach((middleware) => middleware({
|
|
5536
|
-
navigation: this,
|
|
5537
|
-
event: ev,
|
|
5538
|
-
routeName: this.currentRouteName(),
|
|
5539
|
-
props: this.currentQuery() || undefined,
|
|
5540
|
-
parser: this.options.useHashtagParser ? "hashtag" : "directory"
|
|
5541
|
-
}));
|
|
5542
|
-
this.emitter.dispatch("navigate", {
|
|
5543
|
-
navigation: this,
|
|
5544
|
-
routeName,
|
|
5545
|
-
parser
|
|
5546
|
-
});
|
|
5547
|
-
this.#oldRoute = routeName;
|
|
5548
|
-
return this;
|
|
5549
|
-
}
|
|
5550
|
-
navigate(route, props, ev) {
|
|
5551
|
-
if (!route) {
|
|
5552
|
-
return this;
|
|
5553
|
-
}
|
|
5554
|
-
const currentRoute = this.currentRouteName();
|
|
5555
|
-
const routeName = route;
|
|
5556
|
-
const hasProps = Object.keys(props || {}).length;
|
|
5557
|
-
const query = hasProps ? `?${urlParams(props || {})}` : "";
|
|
5558
|
-
if (currentRoute != routeName) {
|
|
5559
|
-
if (this.options.useHashtagParser) {
|
|
5560
|
-
location.hash = `${routeName}${query}`;
|
|
5561
|
-
} else {
|
|
5562
|
-
history.pushState(props || {}, document.title, `${routeName}${query}`);
|
|
5563
|
-
this.dispatchNavigate(ev || undefined);
|
|
5564
|
-
}
|
|
5565
|
-
} else {
|
|
5566
|
-
this.dispatchNavigate(ev || undefined);
|
|
5567
|
-
}
|
|
5568
|
-
return this;
|
|
5569
|
-
}
|
|
5570
|
-
};
|
|
5571
|
-
var MetricRandom = class {
|
|
5572
|
-
static ALPHA_NUMERIC = "a b c d e f g h i j k l m n o p q r s t u v w x y z A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9";
|
|
5573
|
-
static ALPHA_NUMERIC_LOWER = "a b c d e f g h i j k l m n o p q r s t u v w x y z 0 1 2 3 4 5 6 7 8 9";
|
|
5574
|
-
static ALPHA_NUMERIC_UPPER = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z 0 1 2 3 4 5 6 7 8 9";
|
|
5575
|
-
static ALPHA_UPPER = "A B C D E F G H I J K L M N O P Q R S T U V W X Y Z";
|
|
5576
|
-
static ALPHA_LOWER = "a b c d e f g h i j k l m n o p q r s t u v w x y z";
|
|
5577
|
-
static HEX_UPPER = "A B C D E F 0 1 2 3 4 5 6 7 8 9";
|
|
5578
|
-
static HEX_LOWER = "a b c d e f 0 1 2 3 4 5 6 7 8 9";
|
|
5579
|
-
static NUMERIC = "0 1 2 3 4 5 6 7 8 9";
|
|
5580
|
-
static CreateRandom(min, max) {
|
|
5581
|
-
return Math.floor(Math.random() * (max - min) + min);
|
|
5582
|
-
}
|
|
5583
|
-
static CreateBlock(base, length) {
|
|
5584
|
-
let based, out = [];
|
|
5585
|
-
based = base.split(" ");
|
|
5586
|
-
if (Array.isArray(based)) {
|
|
5587
|
-
for (let x = 0;x < length; x++) {
|
|
5588
|
-
const k = this.CreateRandom(0, based.length - 1);
|
|
5589
|
-
out[out.length] = based[k];
|
|
5590
|
-
}
|
|
5591
|
-
}
|
|
5592
|
-
return out;
|
|
5593
|
-
}
|
|
5594
|
-
static CreateAlpha(length) {
|
|
5595
|
-
return this.CreateBlock(`${this.ALPHA_LOWER} ${this.ALPHA_UPPER}`, length);
|
|
5596
|
-
}
|
|
5597
|
-
static CreateHEX(length) {
|
|
5598
|
-
return this.CreateBlock(`${this.HEX_UPPER} ${this.HEX_LOWER}`, length);
|
|
5599
|
-
}
|
|
5600
|
-
static CreateNumeric(length) {
|
|
5601
|
-
return this.CreateBlock(`${this.NUMERIC}`, length);
|
|
5602
|
-
}
|
|
5603
|
-
static Create(length) {
|
|
5604
|
-
return this.CreateBlock(`${this.ALPHA_NUMERIC}`, length);
|
|
5605
|
-
}
|
|
5606
|
-
};
|
|
5607
5436
|
var unCamelCase = TextUtility.unCamelCase;
|
|
5608
|
-
function CoreAppearanceProps(name, value) {
|
|
5609
|
-
const keys = [];
|
|
5610
|
-
const parsed = {};
|
|
5611
|
-
switch (name) {
|
|
5612
|
-
case "paddingVertical":
|
|
5613
|
-
keys.push("paddingTop");
|
|
5614
|
-
keys.push("paddingBottom");
|
|
5615
|
-
break;
|
|
5616
|
-
case "paddingHorizontal":
|
|
5617
|
-
keys.push("paddingLeft");
|
|
5618
|
-
keys.push("paddingRight");
|
|
5619
|
-
break;
|
|
5620
|
-
case "marginVertical":
|
|
5621
|
-
keys.push("marginTop");
|
|
5622
|
-
keys.push("marginBottom");
|
|
5623
|
-
break;
|
|
5624
|
-
case "marginHorizontal":
|
|
5625
|
-
keys.push("marginLeft");
|
|
5626
|
-
keys.push("marginRight");
|
|
5627
|
-
break;
|
|
5628
|
-
default:
|
|
5629
|
-
keys.push(name);
|
|
5630
|
-
break;
|
|
5631
|
-
}
|
|
5632
|
-
keys.forEach((key) => {
|
|
5633
|
-
parsed[unCamelCase(key)] = CoreAppearanceValues(value);
|
|
5634
|
-
});
|
|
5635
|
-
return parsed;
|
|
5636
|
-
}
|
|
5637
|
-
function CoreAppearanceValues(value) {
|
|
5638
|
-
if (typeof value == "number") {
|
|
5639
|
-
return `${value}`;
|
|
5640
|
-
}
|
|
5641
|
-
return value;
|
|
5642
|
-
}
|
|
5643
|
-
var CoreAppearance = class {
|
|
5644
|
-
instance;
|
|
5645
|
-
uid;
|
|
5646
|
-
emitter = new EventDispatcher;
|
|
5647
|
-
properties = {};
|
|
5648
|
-
constructor() {
|
|
5649
|
-
this.instance = document.createElement("style");
|
|
5650
|
-
this.uid = `${MetricRandom.CreateAlpha(4).join("")}-${MetricRandom.Create(12).join("")}`;
|
|
5651
|
-
}
|
|
5652
|
-
sheet(stylesheet) {
|
|
5653
|
-
const styleSheet = [];
|
|
5654
|
-
Object.entries(stylesheet).forEach(({ 0: name, 1: props }) => {
|
|
5655
|
-
const properties = {};
|
|
5656
|
-
const selector = name.includes("&") ? name.replace(new RegExp("&", "g"), `.${this.uid}`) : `.${this.uid} ${name}`;
|
|
5657
|
-
const data = this.insertProperties(properties, props);
|
|
5658
|
-
styleSheet[styleSheet.length] = `${selector}{ ${ObjectUtility.toString(data, { joiner: "; " })} }`;
|
|
5659
|
-
});
|
|
5660
|
-
this.instance.innerHTML = styleSheet.join(" ");
|
|
5661
|
-
this.mountImmediat();
|
|
5662
|
-
return this;
|
|
5663
|
-
}
|
|
5664
|
-
inject(code) {
|
|
5665
|
-
this.instance.innerHTML = typeof code != "string" ? code.join(" ") : code;
|
|
5666
|
-
this.mountImmediat();
|
|
5667
|
-
return this;
|
|
5668
|
-
}
|
|
5669
|
-
insertProperties(properties, data) {
|
|
5670
|
-
Object.entries(data).forEach(({ 0: name, 1: value }) => {
|
|
5671
|
-
Object.entries(CoreAppearanceProps(name, value)).forEach(({ 0: key, 1: data2 }) => properties[key] = data2);
|
|
5672
|
-
});
|
|
5673
|
-
this.emitter.dispatch("insertProperties", properties);
|
|
5674
|
-
return properties;
|
|
5675
|
-
}
|
|
5676
|
-
removeProperties(properties, payload) {
|
|
5677
|
-
Object.values(payload).forEach((name) => {
|
|
5678
|
-
Object.entries(CoreAppearanceProps(name, undefined)).forEach(({ 0: key }) => properties[key] = undefined);
|
|
5679
|
-
});
|
|
5680
|
-
this.emitter.dispatch("removeProperties", properties);
|
|
5681
|
-
return properties;
|
|
5682
|
-
}
|
|
5683
|
-
set(properties) {
|
|
5684
|
-
this.insertProperties(this.properties, properties);
|
|
5685
|
-
this.emitter.dispatch("set", properties);
|
|
5686
|
-
return this.sync();
|
|
5687
|
-
}
|
|
5688
|
-
unset(properties) {
|
|
5689
|
-
this.removeProperties(this.properties, properties);
|
|
5690
|
-
this.emitter.dispatch("unset", properties);
|
|
5691
|
-
return this.sync();
|
|
5692
|
-
}
|
|
5693
|
-
mount() {
|
|
5694
|
-
const length = Object.values(this.properties).length;
|
|
5695
|
-
if (!this.instance.isConnected && length) {
|
|
5696
|
-
this.mountImmediat();
|
|
5697
|
-
}
|
|
5698
|
-
return this;
|
|
5699
|
-
}
|
|
5700
|
-
mountImmediat() {
|
|
5701
|
-
let head = document.querySelector("head");
|
|
5702
|
-
if (!head) {
|
|
5703
|
-
head = document.createElement("head");
|
|
5704
|
-
document.documentElement.append(head);
|
|
5705
|
-
}
|
|
5706
|
-
head.append(this.instance);
|
|
5707
|
-
this.emitter.dispatch("mount", this);
|
|
5708
|
-
return this;
|
|
5709
|
-
}
|
|
5710
|
-
destroy() {
|
|
5711
|
-
this.instance.remove();
|
|
5712
|
-
this.emitter.dispatch("destroy", undefined);
|
|
5713
|
-
return this;
|
|
5714
|
-
}
|
|
5715
|
-
sync() {
|
|
5716
|
-
const rendering = [];
|
|
5717
|
-
Object.entries(this.properties).forEach(({ 0: name, 1: value }) => {
|
|
5718
|
-
if (typeof value == "string" || typeof value == "number") {
|
|
5719
|
-
rendering[rendering.length] = `${unCamelCase(name)} : ${value}`;
|
|
5720
|
-
}
|
|
5721
|
-
});
|
|
5722
|
-
this.instance.innerHTML = `.${this.uid}{ ${rendering.join(";")} }`;
|
|
5723
|
-
this.emitter.dispatch("sync", this);
|
|
5724
|
-
this.mount();
|
|
5725
|
-
return this;
|
|
5726
|
-
}
|
|
5727
|
-
};
|
|
5728
5437
|
var Signal;
|
|
5729
5438
|
((Signal2) => {
|
|
5730
5439
|
|
|
@@ -6220,14 +5929,6 @@ function isArtifact(filename, artifact) {
|
|
|
6220
5929
|
filename.endsWith(`.${artifact}.cjs`)
|
|
6221
5930
|
].some(Boolean);
|
|
6222
5931
|
}
|
|
6223
|
-
// source/framework/utilities/json.util.ts
|
|
6224
|
-
function tryParseJson(obj) {
|
|
6225
|
-
try {
|
|
6226
|
-
return JSON.parse(obj);
|
|
6227
|
-
} catch (e) {
|
|
6228
|
-
return null;
|
|
6229
|
-
}
|
|
6230
|
-
}
|
|
6231
5932
|
// source/framework/utilities/path.util.ts
|
|
6232
5933
|
import path2 from "node:path";
|
|
6233
5934
|
import { fileURLToPath } from "node:url";
|
|
@@ -6261,122 +5962,6 @@ var METADATA_KEYS = {
|
|
|
6261
5962
|
API_PROPERTY: Symbol("api:property"),
|
|
6262
5963
|
ROUTE_INTERACTION: Symbol("route:interaction")
|
|
6263
5964
|
};
|
|
6264
|
-
// source/framework/responses/http.ts
|
|
6265
|
-
class HttpResponse {
|
|
6266
|
-
response;
|
|
6267
|
-
static push(response) {
|
|
6268
|
-
throw new ThrowableResponse({
|
|
6269
|
-
statusCode: response.statusCode || 400 /* BAD_REQUEST */,
|
|
6270
|
-
message: response.message || "No response message provided",
|
|
6271
|
-
data: response.data,
|
|
6272
|
-
error: response.error,
|
|
6273
|
-
errorStack: response.errorStack
|
|
6274
|
-
});
|
|
6275
|
-
}
|
|
6276
|
-
constructor(response) {
|
|
6277
|
-
this.response = response;
|
|
6278
|
-
}
|
|
6279
|
-
status(statusCode) {
|
|
6280
|
-
this.response.statusCode = statusCode;
|
|
6281
|
-
return this;
|
|
6282
|
-
}
|
|
6283
|
-
message(message) {
|
|
6284
|
-
this.response.message = message;
|
|
6285
|
-
return this;
|
|
6286
|
-
}
|
|
6287
|
-
data(data) {
|
|
6288
|
-
this.response.data = data;
|
|
6289
|
-
return this;
|
|
6290
|
-
}
|
|
6291
|
-
error(error) {
|
|
6292
|
-
this.response.error = error;
|
|
6293
|
-
return this;
|
|
6294
|
-
}
|
|
6295
|
-
stack(stack) {
|
|
6296
|
-
this.response.errorStack = stack;
|
|
6297
|
-
return this;
|
|
6298
|
-
}
|
|
6299
|
-
render() {
|
|
6300
|
-
return new ThrowableResponse({ ...this.response }).render();
|
|
6301
|
-
}
|
|
6302
|
-
}
|
|
6303
|
-
|
|
6304
|
-
// source/framework/responses/error.ts
|
|
6305
|
-
class HttpErrorResponse {
|
|
6306
|
-
stack = new Map;
|
|
6307
|
-
get entries() {
|
|
6308
|
-
return [...this.stack.values()];
|
|
6309
|
-
}
|
|
6310
|
-
add(input) {
|
|
6311
|
-
this.stack.set(input.id, input);
|
|
6312
|
-
return this;
|
|
6313
|
-
}
|
|
6314
|
-
remove(id) {
|
|
6315
|
-
this.stack.delete(id);
|
|
6316
|
-
return this;
|
|
6317
|
-
}
|
|
6318
|
-
get(id) {
|
|
6319
|
-
return this.stack.get(id);
|
|
6320
|
-
}
|
|
6321
|
-
has(id) {
|
|
6322
|
-
return this.stack.has(id);
|
|
6323
|
-
}
|
|
6324
|
-
clear() {
|
|
6325
|
-
this.stack.clear();
|
|
6326
|
-
return this;
|
|
6327
|
-
}
|
|
6328
|
-
get empty() {
|
|
6329
|
-
return this.stack.size === 0;
|
|
6330
|
-
}
|
|
6331
|
-
get existence() {
|
|
6332
|
-
return this.stack.size;
|
|
6333
|
-
}
|
|
6334
|
-
push() {
|
|
6335
|
-
const first = this.stack.values().next().value;
|
|
6336
|
-
HttpResponse.push({
|
|
6337
|
-
statusCode: 500,
|
|
6338
|
-
message: first?.message || "Internal server error",
|
|
6339
|
-
error: true,
|
|
6340
|
-
errorStack: this.entries
|
|
6341
|
-
});
|
|
6342
|
-
}
|
|
6343
|
-
}
|
|
6344
|
-
// source/framework/responses/http-throwable.ts
|
|
6345
|
-
class ThrowableResponse extends Error {
|
|
6346
|
-
input;
|
|
6347
|
-
statusCode;
|
|
6348
|
-
constructor(input, statusCode = 500 /* INTERNAL_SERVER_ERROR */) {
|
|
6349
|
-
super(typeof input === "string" ? input : input.message);
|
|
6350
|
-
this.input = input;
|
|
6351
|
-
this.statusCode = statusCode;
|
|
6352
|
-
}
|
|
6353
|
-
render() {
|
|
6354
|
-
const stack = typeof this.input === "object" ? this.input.errorStack : undefined;
|
|
6355
|
-
return {
|
|
6356
|
-
message: this.message,
|
|
6357
|
-
statusCode: this.statusCode,
|
|
6358
|
-
data: typeof this.input === "object" ? this.input.data : undefined,
|
|
6359
|
-
error: typeof this.input === "object" ? this.input.error : false,
|
|
6360
|
-
stack: stack instanceof Error ? Raiton.thread?.builder?.options?.serve ? this.stack?.split(`
|
|
6361
|
-
`).map((e) => e.trim()) : undefined : stack
|
|
6362
|
-
};
|
|
6363
|
-
}
|
|
6364
|
-
}
|
|
6365
|
-
// source/framework/responses/helpers.ts
|
|
6366
|
-
function RaitonResponses(message, data, statusCode, metadata) {
|
|
6367
|
-
if (metadata) {
|
|
6368
|
-
if (metadata.error === undefined) {
|
|
6369
|
-
metadata.error = typeof data?.error === "boolean" ? data?.error : false;
|
|
6370
|
-
}
|
|
6371
|
-
metadata.errorStack = metadata.errorStack instanceof Error ? metadata.errorStack : Raiton.thread?.builder?.options?.serve ? Array.isArray(metadata.errorStack) ? metadata.errorStack : [] : undefined;
|
|
6372
|
-
}
|
|
6373
|
-
return {
|
|
6374
|
-
...metadata,
|
|
6375
|
-
statusCode,
|
|
6376
|
-
message,
|
|
6377
|
-
data
|
|
6378
|
-
};
|
|
6379
|
-
}
|
|
6380
5965
|
// source/core/controller/metadata.ts
|
|
6381
5966
|
var import_reflect_metadata = __toESM(require_Reflect2(), 1);
|
|
6382
5967
|
function getControllerMetadata(target) {
|
|
@@ -6387,162 +5972,6 @@ function getControllerMetadata(target) {
|
|
|
6387
5972
|
}
|
|
6388
5973
|
return metadata;
|
|
6389
5974
|
}
|
|
6390
|
-
// source/core/router/route.ts
|
|
6391
|
-
class Route {
|
|
6392
|
-
method;
|
|
6393
|
-
path;
|
|
6394
|
-
version;
|
|
6395
|
-
handler;
|
|
6396
|
-
parameters = {};
|
|
6397
|
-
constructor(def) {
|
|
6398
|
-
this.method = def.method;
|
|
6399
|
-
this.path = def.path;
|
|
6400
|
-
this.version = def.version;
|
|
6401
|
-
this.handler = def.handler;
|
|
6402
|
-
}
|
|
6403
|
-
get params() {
|
|
6404
|
-
const fullPath = this.version ? `/${this.version}${this.path}` : this.path;
|
|
6405
|
-
const matches = fullPath.match(/:[a-zA-Z0-9_]+/g);
|
|
6406
|
-
return matches ? matches.map((m) => m.substring(1)) : [];
|
|
6407
|
-
}
|
|
6408
|
-
get name() {
|
|
6409
|
-
return this.handler.name;
|
|
6410
|
-
}
|
|
6411
|
-
extractParams(url) {
|
|
6412
|
-
const fullPath = (this.version ? `/${this.version}${this.path}` : this.path).replace(/\/+$/, "");
|
|
6413
|
-
const paramNames = this.params;
|
|
6414
|
-
if (paramNames.length === 0)
|
|
6415
|
-
return this;
|
|
6416
|
-
const regexPath = fullPath.replace(/:[a-zA-Z0-9_]+/g, "([^/]+)");
|
|
6417
|
-
const regex = new RegExp(`^${regexPath || "/"}/?$`);
|
|
6418
|
-
const matches = url.match(regex);
|
|
6419
|
-
if (matches) {
|
|
6420
|
-
const params = {};
|
|
6421
|
-
paramNames.forEach((name, index) => {
|
|
6422
|
-
params[name] = matches[index + 1];
|
|
6423
|
-
});
|
|
6424
|
-
this.parameters = params;
|
|
6425
|
-
}
|
|
6426
|
-
return this;
|
|
6427
|
-
}
|
|
6428
|
-
match(method, url) {
|
|
6429
|
-
if (method !== this.method)
|
|
6430
|
-
return false;
|
|
6431
|
-
const fullPath = (this.version ? `/${this.version}${this.path}` : this.path).replace(/\/+$/, "");
|
|
6432
|
-
const cleanUrl = url.replace(/\/+$/, "");
|
|
6433
|
-
if (!fullPath.includes(":")) {
|
|
6434
|
-
return (fullPath || "/") === (cleanUrl || "/");
|
|
6435
|
-
}
|
|
6436
|
-
const regexPath = fullPath.replace(/:[a-zA-Z0-9_]+/g, "([^/]+)");
|
|
6437
|
-
const regex = new RegExp(`^${regexPath || "/"}/?$`);
|
|
6438
|
-
return regex.test(url);
|
|
6439
|
-
}
|
|
6440
|
-
}
|
|
6441
|
-
// source/core/router/matcher.ts
|
|
6442
|
-
class RouteMatcher {
|
|
6443
|
-
_routes = new Map;
|
|
6444
|
-
getKey(route) {
|
|
6445
|
-
return `${route.method}:${route.path}`;
|
|
6446
|
-
}
|
|
6447
|
-
get routes() {
|
|
6448
|
-
return this._routes;
|
|
6449
|
-
}
|
|
6450
|
-
add(route) {
|
|
6451
|
-
this._routes.set(this.getKey(route), route);
|
|
6452
|
-
return this;
|
|
6453
|
-
}
|
|
6454
|
-
has(route) {
|
|
6455
|
-
return this._routes.has(this.getKey(route));
|
|
6456
|
-
}
|
|
6457
|
-
find(route) {
|
|
6458
|
-
return this._routes.get(this.getKey(route));
|
|
6459
|
-
}
|
|
6460
|
-
replace(route) {
|
|
6461
|
-
if (this.has(route)) {
|
|
6462
|
-
this._routes.set(this.getKey(route), route);
|
|
6463
|
-
}
|
|
6464
|
-
return this;
|
|
6465
|
-
}
|
|
6466
|
-
upsert(route) {
|
|
6467
|
-
this._routes.set(this.getKey(route), route);
|
|
6468
|
-
return this;
|
|
6469
|
-
}
|
|
6470
|
-
remove(route) {
|
|
6471
|
-
this._routes.delete(this.getKey(route));
|
|
6472
|
-
return this;
|
|
6473
|
-
}
|
|
6474
|
-
match(method, url) {
|
|
6475
|
-
for (const route of this._routes.values())
|
|
6476
|
-
if (route.match(method, url))
|
|
6477
|
-
return route.extractParams(url);
|
|
6478
|
-
return null;
|
|
6479
|
-
}
|
|
6480
|
-
clear() {
|
|
6481
|
-
this._routes.clear();
|
|
6482
|
-
return this;
|
|
6483
|
-
}
|
|
6484
|
-
}
|
|
6485
|
-
// source/core/router/router.ts
|
|
6486
|
-
class Router {
|
|
6487
|
-
matcher = new RouteMatcher;
|
|
6488
|
-
add(method, path3, handler, version2) {
|
|
6489
|
-
const route = new Route({
|
|
6490
|
-
method,
|
|
6491
|
-
path: path3,
|
|
6492
|
-
handler,
|
|
6493
|
-
version: version2
|
|
6494
|
-
});
|
|
6495
|
-
this.matcher.add(route);
|
|
6496
|
-
return route;
|
|
6497
|
-
}
|
|
6498
|
-
remove(route) {
|
|
6499
|
-
this.matcher.remove(route);
|
|
6500
|
-
}
|
|
6501
|
-
match(method, url) {
|
|
6502
|
-
return this.matcher.match(method, url);
|
|
6503
|
-
}
|
|
6504
|
-
reset() {
|
|
6505
|
-
this.matcher.clear();
|
|
6506
|
-
}
|
|
6507
|
-
getRoutes() {
|
|
6508
|
-
return Array.from(this.matcher.routes.values());
|
|
6509
|
-
}
|
|
6510
|
-
}
|
|
6511
|
-
// source/framework/exceptions/http-exception.ts
|
|
6512
|
-
class HttpException extends Error {
|
|
6513
|
-
statusCode;
|
|
6514
|
-
errorCode;
|
|
6515
|
-
constructor(error2, statusCode = 500 /* INTERNAL_SERVER_ERROR */, errorCode = undefined) {
|
|
6516
|
-
super(typeof error2 === "string" ? error2 : error2.message);
|
|
6517
|
-
this.statusCode = statusCode;
|
|
6518
|
-
this.errorCode = errorCode;
|
|
6519
|
-
}
|
|
6520
|
-
setStatus(statusCode) {
|
|
6521
|
-
this.statusCode = statusCode;
|
|
6522
|
-
return this;
|
|
6523
|
-
}
|
|
6524
|
-
setErrorCode(code) {
|
|
6525
|
-
this.errorCode = code;
|
|
6526
|
-
return this;
|
|
6527
|
-
}
|
|
6528
|
-
setMessage(error2) {
|
|
6529
|
-
this.message = typeof error2 === "string" ? error2 : error2.message;
|
|
6530
|
-
return this;
|
|
6531
|
-
}
|
|
6532
|
-
render() {
|
|
6533
|
-
return {
|
|
6534
|
-
message: this.message,
|
|
6535
|
-
statusCode: this.statusCode,
|
|
6536
|
-
errorCode: this.errorCode,
|
|
6537
|
-
error: true,
|
|
6538
|
-
stack: Raiton.thread?.builder?.options?.serve ? this.stack?.split(`
|
|
6539
|
-
`).map((e) => e.trim()) : undefined
|
|
6540
|
-
};
|
|
6541
|
-
}
|
|
6542
|
-
toString() {
|
|
6543
|
-
return `HttpException: ${this.message} with status code ${this.statusCode}`;
|
|
6544
|
-
}
|
|
6545
|
-
}
|
|
6546
5975
|
// source/framework/exceptions/throwable.ts
|
|
6547
5976
|
class Throwable extends Error {
|
|
6548
5977
|
statusCode;
|
|
@@ -6591,7 +6020,7 @@ class Injection {
|
|
|
6591
6020
|
return this._classes.has(this.normalizeName(name));
|
|
6592
6021
|
}
|
|
6593
6022
|
static clear() {
|
|
6594
|
-
Logger.
|
|
6023
|
+
Logger.info("Clearing injection container");
|
|
6595
6024
|
this._classes.clear();
|
|
6596
6025
|
this._instances.clear();
|
|
6597
6026
|
this._dependents.clear();
|
|
@@ -6779,158 +6208,6 @@ var controllerRouteMap = new Map;
|
|
|
6779
6208
|
// source/core/socket/metadata.ts
|
|
6780
6209
|
var import_reflect_metadata3 = __toESM(require_Reflect2(), 1);
|
|
6781
6210
|
var registry = new Map;
|
|
6782
|
-
// source/framework/plugins/body-parser.plugin.ts
|
|
6783
|
-
function bodyParserPlugin() {
|
|
6784
|
-
return {
|
|
6785
|
-
name: "body-parser-plugin",
|
|
6786
|
-
setup: (scope) => {
|
|
6787
|
-
scope.use(async ({ context, next }) => {
|
|
6788
|
-
readQueryBody(context);
|
|
6789
|
-
const isGetOrHead = ["GET", "HEAD"].includes(context.req.method.toUpperCase());
|
|
6790
|
-
if (isGetOrHead) {
|
|
6791
|
-
context.req.body = context.req.query;
|
|
6792
|
-
}
|
|
6793
|
-
const hasBody = context.req.body !== undefined && context.req.body !== null;
|
|
6794
|
-
if (hasBody && !context.state.bodyParsed && !isGetOrHead) {
|
|
6795
|
-
try {
|
|
6796
|
-
const contentType = context.req.headers.get("content-type") || "";
|
|
6797
|
-
const rawBody = await readRawBody(context.req.body);
|
|
6798
|
-
const bodyString = decode(rawBody);
|
|
6799
|
-
await readMultipartBody(context, contentType, rawBody);
|
|
6800
|
-
readJsonBody(context, contentType, bodyString);
|
|
6801
|
-
readUrlEncodedBody(context, contentType, bodyString);
|
|
6802
|
-
readTextBody(context, contentType, bodyString);
|
|
6803
|
-
if (!context.state.bodyParsed) {
|
|
6804
|
-
context.req.body = rawBody;
|
|
6805
|
-
context.state.bodyParsed = true;
|
|
6806
|
-
}
|
|
6807
|
-
} catch (e) {
|
|
6808
|
-
Logger.error("Error parsing body:", e);
|
|
6809
|
-
}
|
|
6810
|
-
}
|
|
6811
|
-
await next();
|
|
6812
|
-
});
|
|
6813
|
-
}
|
|
6814
|
-
};
|
|
6815
|
-
}
|
|
6816
|
-
function readJsonBody(ctx, contentType, body) {
|
|
6817
|
-
if (contentType.includes("application/json")) {
|
|
6818
|
-
ctx.req.body = tryParseJson(body) || {};
|
|
6819
|
-
ctx.state.bodyParsed = true;
|
|
6820
|
-
}
|
|
6821
|
-
}
|
|
6822
|
-
async function readMultipartBody(ctx, contentType, rawBody) {
|
|
6823
|
-
if (contentType.includes("multipart/form-data")) {
|
|
6824
|
-
try {
|
|
6825
|
-
const tempRequest = new Request(ctx.req.url, {
|
|
6826
|
-
method: ctx.req.method,
|
|
6827
|
-
headers: ctx.req.headers,
|
|
6828
|
-
body: rawBody
|
|
6829
|
-
});
|
|
6830
|
-
const formData = await tempRequest.formData();
|
|
6831
|
-
const record = {};
|
|
6832
|
-
const files = {};
|
|
6833
|
-
for (const [key, value] of formData.entries()) {
|
|
6834
|
-
const v = value;
|
|
6835
|
-
if (v && v instanceof File) {
|
|
6836
|
-
files[key] = {
|
|
6837
|
-
name: v.name,
|
|
6838
|
-
type: v.type,
|
|
6839
|
-
size: v.size,
|
|
6840
|
-
lastModified: v.lastModified,
|
|
6841
|
-
buffer: Buffer.from(await v.arrayBuffer())
|
|
6842
|
-
};
|
|
6843
|
-
} else {
|
|
6844
|
-
record[key] = value;
|
|
6845
|
-
}
|
|
6846
|
-
}
|
|
6847
|
-
ctx.req.body = record;
|
|
6848
|
-
ctx.req.files = files;
|
|
6849
|
-
ctx.req.file = Object.values(files)[0] || null;
|
|
6850
|
-
ctx.state.bodyParsed = true;
|
|
6851
|
-
} catch (e) {
|
|
6852
|
-
Logger.error("Error parsing multipart body:", e);
|
|
6853
|
-
}
|
|
6854
|
-
}
|
|
6855
|
-
}
|
|
6856
|
-
function readUrlEncodedBody(ctx, contentType, body) {
|
|
6857
|
-
if (contentType.includes("application/x-www-form-urlencoded")) {
|
|
6858
|
-
const params = new URLSearchParams(body);
|
|
6859
|
-
const record = {};
|
|
6860
|
-
params.forEach((value, key) => {
|
|
6861
|
-
record[key] = value;
|
|
6862
|
-
});
|
|
6863
|
-
ctx.req.body = record;
|
|
6864
|
-
ctx.state.bodyParsed = true;
|
|
6865
|
-
}
|
|
6866
|
-
}
|
|
6867
|
-
function readTextBody(ctx, contentType, body) {
|
|
6868
|
-
if (contentType.includes("text/")) {
|
|
6869
|
-
ctx.req.body = body;
|
|
6870
|
-
ctx.state.bodyParsed = true;
|
|
6871
|
-
}
|
|
6872
|
-
}
|
|
6873
|
-
function readQueryBody(ctx) {
|
|
6874
|
-
const searchParams = new URLSearchParams(ctx.req.url.split("?")[1] || "");
|
|
6875
|
-
const record = {};
|
|
6876
|
-
searchParams.forEach((value, key) => record[key] = value);
|
|
6877
|
-
ctx.req.query = record;
|
|
6878
|
-
}
|
|
6879
|
-
async function readRawBody(body) {
|
|
6880
|
-
if (!body)
|
|
6881
|
-
return new Uint8Array(0);
|
|
6882
|
-
if (body instanceof Uint8Array || typeof body === "string") {
|
|
6883
|
-
return body;
|
|
6884
|
-
}
|
|
6885
|
-
if (typeof body === "object" && !("on" in body) && !(body instanceof ReadableStream)) {
|
|
6886
|
-
return JSON.stringify(body);
|
|
6887
|
-
}
|
|
6888
|
-
if (body instanceof ReadableStream) {
|
|
6889
|
-
const reader = body.getReader();
|
|
6890
|
-
const chunks = [];
|
|
6891
|
-
while (true) {
|
|
6892
|
-
const { done, value } = await reader.read();
|
|
6893
|
-
if (done)
|
|
6894
|
-
break;
|
|
6895
|
-
chunks.push(value);
|
|
6896
|
-
}
|
|
6897
|
-
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
6898
|
-
const result = new Uint8Array(totalLength);
|
|
6899
|
-
let offset = 0;
|
|
6900
|
-
for (const chunk of chunks) {
|
|
6901
|
-
result.set(chunk, offset);
|
|
6902
|
-
offset += chunk.length;
|
|
6903
|
-
}
|
|
6904
|
-
return result;
|
|
6905
|
-
}
|
|
6906
|
-
if (typeof body === "object" && body !== null && "on" in body && typeof body.on === "function") {
|
|
6907
|
-
return new Promise((resolve, reject) => {
|
|
6908
|
-
const chunks = [];
|
|
6909
|
-
body.on("data", (chunk) => chunks.push(chunk));
|
|
6910
|
-
body.on("end", () => {
|
|
6911
|
-
if (chunks.length > 0 && typeof chunks[0] === "string") {
|
|
6912
|
-
resolve(chunks.join(""));
|
|
6913
|
-
} else {
|
|
6914
|
-
const totalLength = chunks.reduce((acc, chunk) => acc + chunk.length, 0);
|
|
6915
|
-
const result = new Uint8Array(totalLength);
|
|
6916
|
-
let offset = 0;
|
|
6917
|
-
for (const chunk of chunks) {
|
|
6918
|
-
result.set(new Uint8Array(chunk), offset);
|
|
6919
|
-
offset += chunk.length;
|
|
6920
|
-
}
|
|
6921
|
-
resolve(result);
|
|
6922
|
-
}
|
|
6923
|
-
});
|
|
6924
|
-
body.on("error", reject);
|
|
6925
|
-
});
|
|
6926
|
-
}
|
|
6927
|
-
return body;
|
|
6928
|
-
}
|
|
6929
|
-
function decode(data) {
|
|
6930
|
-
if (typeof data === "string")
|
|
6931
|
-
return data;
|
|
6932
|
-
return new TextDecoder().decode(data);
|
|
6933
|
-
}
|
|
6934
6211
|
// source/framework/decorators/routable.decorator.ts
|
|
6935
6212
|
function stabilizeRoute(meta, { path: path3, method, propertyKey }) {
|
|
6936
6213
|
return {
|
|
@@ -7051,170 +6328,6 @@ class RouteInteractionsRegistry {
|
|
|
7051
6328
|
return this.interactions.has(fullPath);
|
|
7052
6329
|
}
|
|
7053
6330
|
}
|
|
7054
|
-
// source/core/hooks.ts
|
|
7055
|
-
class HookStore {
|
|
7056
|
-
hooks = new Map;
|
|
7057
|
-
add(name, handler2) {
|
|
7058
|
-
const list = this.hooks.get(name) ?? [];
|
|
7059
|
-
list.push(handler2);
|
|
7060
|
-
this.hooks.set(name, list);
|
|
7061
|
-
}
|
|
7062
|
-
remove(name, handler2) {
|
|
7063
|
-
if (!this.hooks.has(name))
|
|
7064
|
-
return;
|
|
7065
|
-
if (!handler2) {
|
|
7066
|
-
this.hooks.delete(name);
|
|
7067
|
-
return;
|
|
7068
|
-
}
|
|
7069
|
-
const list = this.hooks.get(name);
|
|
7070
|
-
const idx = list.indexOf(handler2);
|
|
7071
|
-
if (idx !== -1)
|
|
7072
|
-
list.splice(idx, 1);
|
|
7073
|
-
if (list.length === 0)
|
|
7074
|
-
this.hooks.delete(name);
|
|
7075
|
-
else
|
|
7076
|
-
this.hooks.set(name, list);
|
|
7077
|
-
}
|
|
7078
|
-
replace(name, oldHandler, newHandler) {
|
|
7079
|
-
if (!this.hooks.has(name)) {
|
|
7080
|
-
this.add(name, newHandler);
|
|
7081
|
-
return;
|
|
7082
|
-
}
|
|
7083
|
-
const list = this.hooks.get(name);
|
|
7084
|
-
const idx = list.indexOf(oldHandler);
|
|
7085
|
-
if (idx !== -1) {
|
|
7086
|
-
list[idx] = newHandler;
|
|
7087
|
-
} else {
|
|
7088
|
-
list.push(newHandler);
|
|
7089
|
-
}
|
|
7090
|
-
this.hooks.set(name, list);
|
|
7091
|
-
}
|
|
7092
|
-
async run(name, ctx) {
|
|
7093
|
-
const list = this.hooks.get(name);
|
|
7094
|
-
if (!list)
|
|
7095
|
-
return;
|
|
7096
|
-
for (const hook of list) {
|
|
7097
|
-
await hook(ctx);
|
|
7098
|
-
}
|
|
7099
|
-
}
|
|
7100
|
-
}
|
|
7101
|
-
|
|
7102
|
-
// source/core/middleware/compose.ts
|
|
7103
|
-
function middlewareCompose(middlewares) {
|
|
7104
|
-
return function(request) {
|
|
7105
|
-
let index = -1;
|
|
7106
|
-
return dispatch(0);
|
|
7107
|
-
async function dispatch(i) {
|
|
7108
|
-
if (i <= index) {
|
|
7109
|
-
return Promise.reject(new Throwable("next() called multiple times"));
|
|
7110
|
-
}
|
|
7111
|
-
index = i;
|
|
7112
|
-
const fn = middlewares[i];
|
|
7113
|
-
try {
|
|
7114
|
-
if (!fn)
|
|
7115
|
-
return Promise.resolve();
|
|
7116
|
-
if (typeof fn === "function") {
|
|
7117
|
-
return Promise.resolve(fn({ context: request, next: () => dispatch(i + 1) }));
|
|
7118
|
-
}
|
|
7119
|
-
if (typeof fn === "object" && "setup" in fn && typeof fn.setup == "function") {
|
|
7120
|
-
if (fn.setup.length === 1) {
|
|
7121
|
-
await Promise.resolve(fn.setup(request));
|
|
7122
|
-
return await dispatch(i + 1);
|
|
7123
|
-
}
|
|
7124
|
-
return Promise.resolve(fn.setup(request, () => dispatch(i + 1)));
|
|
7125
|
-
}
|
|
7126
|
-
return Promise.resolve();
|
|
7127
|
-
} catch (err) {
|
|
7128
|
-
return Promise.reject(err);
|
|
7129
|
-
}
|
|
7130
|
-
}
|
|
7131
|
-
};
|
|
7132
|
-
}
|
|
7133
|
-
// source/core/middleware/pipeline.ts
|
|
7134
|
-
class MiddlewarePipeline {
|
|
7135
|
-
stack = [];
|
|
7136
|
-
use(mw) {
|
|
7137
|
-
this.stack.push(mw);
|
|
7138
|
-
return this;
|
|
7139
|
-
}
|
|
7140
|
-
replace(name, mw) {
|
|
7141
|
-
const normalized = name.toLowerCase();
|
|
7142
|
-
for (let i = 0;i < this.stack.length; i++) {
|
|
7143
|
-
const entry = this.stack[i];
|
|
7144
|
-
let entryName;
|
|
7145
|
-
if (typeof entry === "function") {
|
|
7146
|
-
entryName = entry.name?.toLowerCase();
|
|
7147
|
-
} else if (typeof entry === "object" && entry !== null && "name" in entry) {
|
|
7148
|
-
entryName = entry.name?.toLowerCase();
|
|
7149
|
-
}
|
|
7150
|
-
if (entryName === normalized) {
|
|
7151
|
-
this.stack[i] = mw;
|
|
7152
|
-
return this;
|
|
7153
|
-
}
|
|
7154
|
-
}
|
|
7155
|
-
this.stack.push(mw);
|
|
7156
|
-
return this;
|
|
7157
|
-
}
|
|
7158
|
-
remove(name) {
|
|
7159
|
-
const normalized = name.toLowerCase();
|
|
7160
|
-
this.stack = this.stack.filter((entry) => {
|
|
7161
|
-
if (typeof entry === "function")
|
|
7162
|
-
return entry.name?.toLowerCase() !== normalized;
|
|
7163
|
-
if (typeof entry === "object" && entry !== null && "name" in entry)
|
|
7164
|
-
return entry.name?.toLowerCase() !== normalized;
|
|
7165
|
-
return true;
|
|
7166
|
-
});
|
|
7167
|
-
return this;
|
|
7168
|
-
}
|
|
7169
|
-
clear() {
|
|
7170
|
-
this.stack = [];
|
|
7171
|
-
return this;
|
|
7172
|
-
}
|
|
7173
|
-
run(ctx, ...extra) {
|
|
7174
|
-
const fn = middlewareCompose([...this.stack, ...extra]);
|
|
7175
|
-
return typeof fn == "function" ? fn(ctx) : undefined;
|
|
7176
|
-
}
|
|
7177
|
-
}
|
|
7178
|
-
// source/core/plugins/scope.ts
|
|
7179
|
-
class PluginScope {
|
|
7180
|
-
hooks;
|
|
7181
|
-
middleware;
|
|
7182
|
-
router;
|
|
7183
|
-
parent;
|
|
7184
|
-
constructor(parent) {
|
|
7185
|
-
this.parent = parent;
|
|
7186
|
-
this.hooks = parent ? parent.hooks : new HookStore;
|
|
7187
|
-
this.middleware = parent ? parent.middleware : new MiddlewarePipeline;
|
|
7188
|
-
this.router = parent ? parent.router : new Router;
|
|
7189
|
-
}
|
|
7190
|
-
addHook(name, fn) {
|
|
7191
|
-
this.hooks.add(name, fn);
|
|
7192
|
-
return this;
|
|
7193
|
-
}
|
|
7194
|
-
use(mw) {
|
|
7195
|
-
if (typeof mw === "object" && mw !== null && "setup" in mw && typeof mw.setup === "function" && mw.setup.length === 1) {
|
|
7196
|
-
mw.setup(this);
|
|
7197
|
-
return this;
|
|
7198
|
-
}
|
|
7199
|
-
this.middleware.use(mw);
|
|
7200
|
-
return this;
|
|
7201
|
-
}
|
|
7202
|
-
route(method, path3, handler2, version2) {
|
|
7203
|
-
return this.router.add(method, path3, handler2, version2);
|
|
7204
|
-
}
|
|
7205
|
-
get(path3, handler2, version2) {
|
|
7206
|
-
return this.route("GET" /* GET */, path3, handler2, version2);
|
|
7207
|
-
}
|
|
7208
|
-
register(plugin) {
|
|
7209
|
-
if (typeof plugin === "object" && plugin !== null && "setup" in plugin && typeof plugin.setup === "function" && plugin.setup.length === 1) {
|
|
7210
|
-
plugin.setup(this);
|
|
7211
|
-
return this;
|
|
7212
|
-
}
|
|
7213
|
-
const child = new PluginScope(this);
|
|
7214
|
-
plugin.setup(child);
|
|
7215
|
-
return this;
|
|
7216
|
-
}
|
|
7217
|
-
}
|
|
7218
6331
|
// source/core/plugins/plugin.ts
|
|
7219
6332
|
function definePlugin(setup, name) {
|
|
7220
6333
|
return { setup, name };
|
|
@@ -7229,107 +6342,6 @@ var secureHeaders = definePlugin((scope2) => {
|
|
|
7229
6342
|
await next();
|
|
7230
6343
|
});
|
|
7231
6344
|
}, "security-headers");
|
|
7232
|
-
|
|
7233
|
-
// source/framework/plugins/security/cors.ts
|
|
7234
|
-
var secureCors = (opts = {}) => {
|
|
7235
|
-
return async ({ context, next }) => {
|
|
7236
|
-
const origin = context.req.headers.get("origin");
|
|
7237
|
-
if (origin) {
|
|
7238
|
-
context.reply.header("Vary", "Origin");
|
|
7239
|
-
}
|
|
7240
|
-
let allowedOrigin = null;
|
|
7241
|
-
if (opts.origin === undefined || opts.origin === "*") {
|
|
7242
|
-
allowedOrigin = "*";
|
|
7243
|
-
} else if (opts.origin === true) {
|
|
7244
|
-
allowedOrigin = origin || "*";
|
|
7245
|
-
} else if (typeof opts.origin === "function") {
|
|
7246
|
-
if (origin && await opts.origin(origin)) {
|
|
7247
|
-
allowedOrigin = origin;
|
|
7248
|
-
}
|
|
7249
|
-
} else if (Array.isArray(opts.origin)) {
|
|
7250
|
-
if (origin && opts.origin.includes(origin)) {
|
|
7251
|
-
allowedOrigin = origin;
|
|
7252
|
-
}
|
|
7253
|
-
} else if (typeof opts.origin === "string") {
|
|
7254
|
-
if (opts.origin === origin) {
|
|
7255
|
-
allowedOrigin = origin;
|
|
7256
|
-
} else if (opts.origin === "*") {
|
|
7257
|
-
allowedOrigin = "*";
|
|
7258
|
-
}
|
|
7259
|
-
}
|
|
7260
|
-
if (allowedOrigin) {
|
|
7261
|
-
context.reply.header("Access-Control-Allow-Origin", allowedOrigin);
|
|
7262
|
-
}
|
|
7263
|
-
if (opts.credentials) {
|
|
7264
|
-
context.reply.header("Access-Control-Allow-Credentials", "true");
|
|
7265
|
-
}
|
|
7266
|
-
if (opts.exposeHeaders) {
|
|
7267
|
-
context.reply.header("Access-Control-Expose-Headers", opts.exposeHeaders.join(","));
|
|
7268
|
-
}
|
|
7269
|
-
if (context.req.method === "OPTIONS") {
|
|
7270
|
-
context.reply.header("Access-Control-Allow-Methods", (opts.methods ?? ["GET", "POST", "PUT", "DELETE", "PATCH"]).join(","));
|
|
7271
|
-
context.reply.header("Access-Control-Allow-Headers", (opts.headers ?? ["Content-Type", "Authorization", "X-Requested-With"]).join(","));
|
|
7272
|
-
if (opts.maxAge) {
|
|
7273
|
-
context.reply.header("Access-Control-Max-Age", opts.maxAge.toString());
|
|
7274
|
-
}
|
|
7275
|
-
context.reply.status(204);
|
|
7276
|
-
return context.send(null);
|
|
7277
|
-
}
|
|
7278
|
-
await next();
|
|
7279
|
-
};
|
|
7280
|
-
};
|
|
7281
|
-
|
|
7282
|
-
// source/framework/plugins/security/rate-limit.ts
|
|
7283
|
-
var secureRateLimit = (opts = {}) => definePlugin((scope2) => {
|
|
7284
|
-
const hits = new Map;
|
|
7285
|
-
const windowMs = opts.windowMs ?? 60000;
|
|
7286
|
-
const max = opts.max ?? 100;
|
|
7287
|
-
scope2.use(async ({ context, next }) => {
|
|
7288
|
-
const ip = context.req.remoteAddress ?? "unknown";
|
|
7289
|
-
const now = Date.now();
|
|
7290
|
-
const entry = hits.get(ip) ?? { count: 0, ts: now };
|
|
7291
|
-
if (now - entry.ts > windowMs) {
|
|
7292
|
-
entry.count = 0;
|
|
7293
|
-
entry.ts = now;
|
|
7294
|
-
}
|
|
7295
|
-
entry.count++;
|
|
7296
|
-
hits.set(ip, entry);
|
|
7297
|
-
if (entry.count > max) {
|
|
7298
|
-
return context.send(RaitonResponses("Too many requests", null, 429 /* TOO_MANY_REQUESTS */, { error: true }));
|
|
7299
|
-
}
|
|
7300
|
-
await next();
|
|
7301
|
-
});
|
|
7302
|
-
}, "rate-limit");
|
|
7303
|
-
|
|
7304
|
-
// source/framework/plugins/security/body-limit.ts
|
|
7305
|
-
var secureBodyLimit = (maxBytes = 1e6) => definePlugin((scope2) => {
|
|
7306
|
-
scope2.use(async ({ context, next }) => {
|
|
7307
|
-
const len = Number(context.req.headers.get("content-length") ?? 0);
|
|
7308
|
-
if (len > maxBytes) {
|
|
7309
|
-
return context.send(RaitonResponses("Payload too large", null, 413 /* PAYLOAD_TOO_LARGE */, { error: true }));
|
|
7310
|
-
}
|
|
7311
|
-
await next();
|
|
7312
|
-
});
|
|
7313
|
-
}, "body-limit");
|
|
7314
|
-
|
|
7315
|
-
// source/framework/plugins/security/method-guard.ts
|
|
7316
|
-
var secureMethodGuard = (allowed) => definePlugin((scope2) => {
|
|
7317
|
-
scope2.use(async ({ context, next }) => {
|
|
7318
|
-
if (!allowed.includes(context.req.method)) {
|
|
7319
|
-
return context.send(RaitonResponses("Method not allowed", null, 405 /* METHOD_NOT_ALLOWED */, { error: true }));
|
|
7320
|
-
}
|
|
7321
|
-
await next();
|
|
7322
|
-
});
|
|
7323
|
-
}, "method-guard");
|
|
7324
|
-
|
|
7325
|
-
// source/framework/plugins/security/index.ts
|
|
7326
|
-
class Security {
|
|
7327
|
-
static headers = secureHeaders;
|
|
7328
|
-
static cors = secureCors;
|
|
7329
|
-
static rateLimit = secureRateLimit;
|
|
7330
|
-
static bodyLimit = secureBodyLimit;
|
|
7331
|
-
static methodGuard = secureMethodGuard;
|
|
7332
|
-
}
|
|
7333
6345
|
// source/framework/encryption.ts
|
|
7334
6346
|
var import_argon2 = __toESM(require_argon2(), 1);
|
|
7335
6347
|
var import_bcrypt = __toESM(require_bcrypt(), 1);
|
|
@@ -7562,176 +6574,6 @@ class RaitonCommands {
|
|
|
7562
6574
|
}
|
|
7563
6575
|
}
|
|
7564
6576
|
}
|
|
7565
|
-
// source/core/context.ts
|
|
7566
|
-
class RequestContext {
|
|
7567
|
-
req;
|
|
7568
|
-
reply;
|
|
7569
|
-
state = {};
|
|
7570
|
-
decorations = new Map;
|
|
7571
|
-
constructor(req, reply) {
|
|
7572
|
-
this.req = req;
|
|
7573
|
-
this.reply = reply;
|
|
7574
|
-
}
|
|
7575
|
-
decorate(key, value) {
|
|
7576
|
-
if (this.decorations.has(key)) {
|
|
7577
|
-
throw new Error(`Decoration "${key}" already exists`);
|
|
7578
|
-
}
|
|
7579
|
-
this.decorations.set(key, value);
|
|
7580
|
-
}
|
|
7581
|
-
get(key) {
|
|
7582
|
-
if (key in this.state)
|
|
7583
|
-
return this.state[key];
|
|
7584
|
-
if (this.decorations.has(key)) {
|
|
7585
|
-
return this.decorations.get(key);
|
|
7586
|
-
}
|
|
7587
|
-
throw new Error(`Context value "${key}" not found`);
|
|
7588
|
-
}
|
|
7589
|
-
send(body) {
|
|
7590
|
-
this.reply.send(body);
|
|
7591
|
-
}
|
|
7592
|
-
}
|
|
7593
|
-
|
|
7594
|
-
// source/core/application.ts
|
|
7595
|
-
class Application {
|
|
7596
|
-
config;
|
|
7597
|
-
root;
|
|
7598
|
-
version = RaitonConfig.get("version") || "0.0.1";
|
|
7599
|
-
static get container() {
|
|
7600
|
-
return Injection;
|
|
7601
|
-
}
|
|
7602
|
-
constructor(config2) {
|
|
7603
|
-
this.config = config2;
|
|
7604
|
-
this.root = new PluginScope;
|
|
7605
|
-
if (this.config.workdir) {
|
|
7606
|
-
process.chdir(this.config.workdir);
|
|
7607
|
-
}
|
|
7608
|
-
this.initialize();
|
|
7609
|
-
}
|
|
7610
|
-
initialize() {
|
|
7611
|
-
const artifacts = RaitonConfig.get("artifacts");
|
|
7612
|
-
const artifactTypes = [...artifacts?.types || [], ...Artifacts.defaultTypes];
|
|
7613
|
-
Artifacts.registerMany(...artifactTypes);
|
|
7614
|
-
this.register(Security.headers);
|
|
7615
|
-
this.register(bodyParserPlugin());
|
|
7616
|
-
return this;
|
|
7617
|
-
}
|
|
7618
|
-
get hostname() {
|
|
7619
|
-
return `${this.config.protocole || "http"}://${this.config.hostname || "localhost"}${this.config.port ? `:${this.config.port}` : ""}${this.config.pathname || "/"}`;
|
|
7620
|
-
}
|
|
7621
|
-
setOption(key, value) {
|
|
7622
|
-
this.config[key] = value;
|
|
7623
|
-
return this;
|
|
7624
|
-
}
|
|
7625
|
-
setOptions(options) {
|
|
7626
|
-
Object.assign(this.config, options);
|
|
7627
|
-
return this;
|
|
7628
|
-
}
|
|
7629
|
-
register(plugin2) {
|
|
7630
|
-
this.root.register(plugin2);
|
|
7631
|
-
return this;
|
|
7632
|
-
}
|
|
7633
|
-
use(mw) {
|
|
7634
|
-
this.root.use(mw);
|
|
7635
|
-
return this;
|
|
7636
|
-
}
|
|
7637
|
-
route(method, path6, handler2, version2) {
|
|
7638
|
-
const prefix = this.config.prefix ?? "";
|
|
7639
|
-
const fullPath = `${prefix}${path6}`.replace(/\/+/g, "/") || "/";
|
|
7640
|
-
this.root.route(method, fullPath, handler2, version2);
|
|
7641
|
-
return this;
|
|
7642
|
-
}
|
|
7643
|
-
get(path6, handler2, version2) {
|
|
7644
|
-
return this.route("GET" /* GET */, path6, handler2, version2);
|
|
7645
|
-
}
|
|
7646
|
-
post(path6, handler2, version2) {
|
|
7647
|
-
return this.route("POST" /* POST */, path6, handler2, version2);
|
|
7648
|
-
}
|
|
7649
|
-
patch(path6, handler2, version2) {
|
|
7650
|
-
return this.route("PATCH" /* PATCH */, path6, handler2, version2);
|
|
7651
|
-
}
|
|
7652
|
-
put(path6, handler2, version2) {
|
|
7653
|
-
return this.route("PUT" /* PUT */, path6, handler2, version2);
|
|
7654
|
-
}
|
|
7655
|
-
delete(path6, handler2, version2) {
|
|
7656
|
-
return this.route("DELETE" /* DELETE */, path6, handler2, version2);
|
|
7657
|
-
}
|
|
7658
|
-
options(path6, handler2, version2) {
|
|
7659
|
-
return this.route("OPTIONS" /* OPTIONS */, path6, handler2, version2);
|
|
7660
|
-
}
|
|
7661
|
-
head(path6, handler2, version2) {
|
|
7662
|
-
return this.route("HEAD" /* HEAD */, path6, handler2, version2);
|
|
7663
|
-
}
|
|
7664
|
-
trace(path6, handler2, version2) {
|
|
7665
|
-
return this.route("TRACE" /* TRACE */, path6, handler2, version2);
|
|
7666
|
-
}
|
|
7667
|
-
async handle(req, reply) {
|
|
7668
|
-
const ctx = new RequestContext(req, reply);
|
|
7669
|
-
if (this.config.verbose) {
|
|
7670
|
-
Logger.info(`Incoming request: ${req.method} ${req.url}`);
|
|
7671
|
-
}
|
|
7672
|
-
await this.root.hooks.run("onRequest", ctx);
|
|
7673
|
-
const handler2 = async (param) => {
|
|
7674
|
-
const context = param.context ?? param;
|
|
7675
|
-
const req2 = context.req;
|
|
7676
|
-
const reply2 = context.reply;
|
|
7677
|
-
const url = new URL(req2.url, this.hostname);
|
|
7678
|
-
let pathname = url.pathname;
|
|
7679
|
-
if (this.config.pathname && this.config.pathname !== "/") {
|
|
7680
|
-
const appPathname = this.config.pathname.endsWith("/") ? this.config.pathname : `${this.config.pathname}/`;
|
|
7681
|
-
if (pathname.startsWith(appPathname)) {
|
|
7682
|
-
pathname = pathname.substring(appPathname.length - 1) || "/";
|
|
7683
|
-
} else if (pathname === this.config.pathname) {
|
|
7684
|
-
pathname = "/";
|
|
7685
|
-
} else {
|
|
7686
|
-
if (this.config.verbose) {
|
|
7687
|
-
Logger.warn(`Request out of application pathname: ${pathname} (expected prefix: ${this.config.pathname})`);
|
|
7688
|
-
}
|
|
7689
|
-
reply2.status(404);
|
|
7690
|
-
return reply2.send(RaitonResponses("Not Found", null, 404 /* NOT_FOUND */, { error: false }));
|
|
7691
|
-
}
|
|
7692
|
-
}
|
|
7693
|
-
const route2 = this.root.router.match(req2.method, pathname);
|
|
7694
|
-
if (!route2) {
|
|
7695
|
-
if (this.config.verbose) {
|
|
7696
|
-
Logger.warn(`Route not found: ${req2.method} ${pathname}`);
|
|
7697
|
-
}
|
|
7698
|
-
reply2.status(404);
|
|
7699
|
-
return reply2.send(RaitonResponses("Not Found", null, 404 /* NOT_FOUND */, { error: false }));
|
|
7700
|
-
}
|
|
7701
|
-
try {
|
|
7702
|
-
context.params = route2.parameters;
|
|
7703
|
-
let responses2 = await route2.handler(context);
|
|
7704
|
-
if (responses2 instanceof ThrowableResponse) {
|
|
7705
|
-
context.reply.status(responses2.statusCode ?? 500);
|
|
7706
|
-
}
|
|
7707
|
-
if (responses2 instanceof HttpException) {
|
|
7708
|
-
context.reply.status(responses2.statusCode ?? 500);
|
|
7709
|
-
}
|
|
7710
|
-
context.reply.send(responses2);
|
|
7711
|
-
} catch (e) {
|
|
7712
|
-
Logger.info(`${req2.method} ${req2.url}`);
|
|
7713
|
-
Logger.error("Failed to execute handle", e.message ?? e);
|
|
7714
|
-
if (this.config.develop) {
|
|
7715
|
-
console.error(e);
|
|
7716
|
-
}
|
|
7717
|
-
context.reply.status(500);
|
|
7718
|
-
context.reply.send(RaitonResponses("Internal Server Error", null, 500 /* INTERNAL_SERVER_ERROR */, { error: true }));
|
|
7719
|
-
}
|
|
7720
|
-
};
|
|
7721
|
-
try {
|
|
7722
|
-
await this.root.middleware.run(ctx, handler2);
|
|
7723
|
-
await this.root.hooks.run("onResponse", ctx);
|
|
7724
|
-
} catch (err) {
|
|
7725
|
-
Logger.info(`${req.method} ${req.url}`);
|
|
7726
|
-
if (err instanceof HttpException || err instanceof ThrowableResponse) {
|
|
7727
|
-
Logger.error(`Server error`, err.message ?? err);
|
|
7728
|
-
ctx.reply.status(err.statusCode ?? 500);
|
|
7729
|
-
return ctx.reply.send(err.render());
|
|
7730
|
-
}
|
|
7731
|
-
ctx.reply.send(RaitonResponses(err.message ?? err, null, 500 /* INTERNAL_SERVER_ERROR */, { error: true }));
|
|
7732
|
-
}
|
|
7733
|
-
}
|
|
7734
|
-
}
|
|
7735
6577
|
// source/bin/cli-tools.ts
|
|
7736
6578
|
import { spawn } from "node:child_process";
|
|
7737
6579
|
|