@navios/core 0.1.1 → 0.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +341 -288
- package/dist/index.d.ts +341 -288
- package/dist/index.js +959 -827
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +951 -827
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/config/config-service.interface.mts +16 -0
- package/src/config/config.provider.mts +63 -0
- package/src/config/config.service.mts +69 -0
- package/src/config/index.mts +5 -0
- package/src/config/types.mts +58 -0
- package/src/config/utils/helpers.mts +23 -0
- package/src/config/utils/index.mts +1 -0
- package/src/index.mts +1 -0
- package/src/service-locator/proxy-service-locator.mts +28 -9
- package/src/service-locator/service-locator.mts +9 -1
package/dist/index.mjs
CHANGED
|
@@ -46,115 +46,117 @@ var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read fr
|
|
|
46
46
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
47
47
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
48
48
|
|
|
49
|
-
// packages/core/src/
|
|
50
|
-
|
|
51
|
-
function
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
if (metadata) {
|
|
55
|
-
return metadata;
|
|
56
|
-
} else {
|
|
57
|
-
context.metadata[EndpointMetadataKey] = /* @__PURE__ */ new Set();
|
|
58
|
-
return context.metadata[EndpointMetadataKey];
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
throw new Error("[Navios] Wrong environment.");
|
|
49
|
+
// packages/core/src/config/utils/helpers.mts
|
|
50
|
+
import { env } from "node:process";
|
|
51
|
+
function envInt(key, defaultValue) {
|
|
52
|
+
const envKey = env[key] || process.env[key];
|
|
53
|
+
return envKey ? parseInt(envKey, 10) : defaultValue;
|
|
62
54
|
}
|
|
63
|
-
function
|
|
64
|
-
|
|
65
|
-
const metadata = getAllEndpointMetadata(context);
|
|
66
|
-
if (metadata) {
|
|
67
|
-
const endpointMetadata = Array.from(metadata).find(
|
|
68
|
-
(item) => item.classMethod === target.name
|
|
69
|
-
);
|
|
70
|
-
if (endpointMetadata) {
|
|
71
|
-
return endpointMetadata;
|
|
72
|
-
} else {
|
|
73
|
-
const newMetadata = {
|
|
74
|
-
classMethod: target.name,
|
|
75
|
-
url: "",
|
|
76
|
-
httpMethod: "GET",
|
|
77
|
-
config: null,
|
|
78
|
-
guards: /* @__PURE__ */ new Set(),
|
|
79
|
-
customAttributes: /* @__PURE__ */ new Map()
|
|
80
|
-
};
|
|
81
|
-
metadata.add(newMetadata);
|
|
82
|
-
return newMetadata;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
throw new Error("[Navios] Wrong environment.");
|
|
55
|
+
function envString(key, defaultValue) {
|
|
56
|
+
return env[key] || process.env[key] || defaultValue || void 0;
|
|
87
57
|
}
|
|
88
58
|
|
|
89
|
-
// packages/core/src/
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
59
|
+
// packages/core/src/config/config.provider.mts
|
|
60
|
+
import { z as z2 } from "zod";
|
|
61
|
+
|
|
62
|
+
// packages/core/src/logger/utils/cli-colors.util.mts
|
|
63
|
+
var isColorAllowed = () => !process.env.NO_COLOR;
|
|
64
|
+
var colorIfAllowed = (colorFn) => (text) => isColorAllowed() ? colorFn(text) : text;
|
|
65
|
+
var clc = {
|
|
66
|
+
bold: colorIfAllowed((text) => `\x1B[1m${text}\x1B[0m`),
|
|
67
|
+
green: colorIfAllowed((text) => `\x1B[32m${text}\x1B[39m`),
|
|
68
|
+
yellow: colorIfAllowed((text) => `\x1B[33m${text}\x1B[39m`),
|
|
69
|
+
red: colorIfAllowed((text) => `\x1B[31m${text}\x1B[39m`),
|
|
70
|
+
magentaBright: colorIfAllowed((text) => `\x1B[95m${text}\x1B[39m`),
|
|
71
|
+
cyanBright: colorIfAllowed((text) => `\x1B[96m${text}\x1B[39m`)
|
|
72
|
+
};
|
|
73
|
+
var yellow = colorIfAllowed(
|
|
74
|
+
(text) => `\x1B[38;5;3m${text}\x1B[39m`
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
// packages/core/src/logger/log-levels.mts
|
|
78
|
+
var LOG_LEVELS = [
|
|
79
|
+
"verbose",
|
|
80
|
+
"debug",
|
|
81
|
+
"log",
|
|
82
|
+
"warn",
|
|
83
|
+
"error",
|
|
84
|
+
"fatal"
|
|
85
|
+
];
|
|
86
|
+
|
|
87
|
+
// packages/core/src/logger/utils/is-log-level.util.mts
|
|
88
|
+
function isLogLevel(maybeLogLevel) {
|
|
89
|
+
return LOG_LEVELS.includes(maybeLogLevel);
|
|
109
90
|
}
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
91
|
+
|
|
92
|
+
// packages/core/src/logger/utils/filter-log-levelts.util.mts
|
|
93
|
+
function filterLogLevels(parseableString = "") {
|
|
94
|
+
const sanitizedString = parseableString.replaceAll(" ", "").toLowerCase();
|
|
95
|
+
if (sanitizedString[0] === ">") {
|
|
96
|
+
const orEqual = sanitizedString[1] === "=";
|
|
97
|
+
const logLevelIndex = LOG_LEVELS.indexOf(
|
|
98
|
+
sanitizedString.substring(orEqual ? 2 : 1)
|
|
115
99
|
);
|
|
100
|
+
if (logLevelIndex === -1) {
|
|
101
|
+
throw new Error(`parse error (unknown log level): ${sanitizedString}`);
|
|
102
|
+
}
|
|
103
|
+
return LOG_LEVELS.slice(orEqual ? logLevelIndex : logLevelIndex + 1);
|
|
104
|
+
} else if (sanitizedString.includes(",")) {
|
|
105
|
+
return sanitizedString.split(",").filter(isLogLevel);
|
|
116
106
|
}
|
|
117
|
-
return
|
|
118
|
-
}
|
|
119
|
-
function hasControllerMetadata(target) {
|
|
120
|
-
const metadata = target[ControllerMetadataKey];
|
|
121
|
-
return !!metadata;
|
|
107
|
+
return isLogLevel(sanitizedString) ? [sanitizedString] : LOG_LEVELS;
|
|
122
108
|
}
|
|
123
109
|
|
|
124
|
-
// packages/core/src/
|
|
125
|
-
var
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
};
|
|
138
|
-
context.metadata[ModuleMetadataKey] = newMetadata;
|
|
139
|
-
target[ModuleMetadataKey] = newMetadata;
|
|
140
|
-
return newMetadata;
|
|
141
|
-
}
|
|
110
|
+
// packages/core/src/logger/utils/is-log-level-enabled.mts
|
|
111
|
+
var LOG_LEVEL_VALUES = {
|
|
112
|
+
verbose: 0,
|
|
113
|
+
debug: 1,
|
|
114
|
+
log: 2,
|
|
115
|
+
warn: 3,
|
|
116
|
+
error: 4,
|
|
117
|
+
fatal: 5
|
|
118
|
+
};
|
|
119
|
+
function isLogLevelEnabled(targetLevel, logLevels) {
|
|
120
|
+
var _a;
|
|
121
|
+
if (!logLevels || Array.isArray(logLevels) && (logLevels == null ? void 0 : logLevels.length) === 0) {
|
|
122
|
+
return false;
|
|
142
123
|
}
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
function extractModuleMetadata(target) {
|
|
146
|
-
const metadata = target[ModuleMetadataKey];
|
|
147
|
-
if (!metadata) {
|
|
148
|
-
throw new Error(
|
|
149
|
-
"[Navios] Module metadata not found. Make sure to use @Module decorator."
|
|
150
|
-
);
|
|
124
|
+
if (logLevels.includes(targetLevel)) {
|
|
125
|
+
return true;
|
|
151
126
|
}
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
return !!target[ModuleMetadataKey];
|
|
127
|
+
const highestLogLevelValue = (_a = logLevels.map((level) => LOG_LEVEL_VALUES[level]).sort((a, b) => b - a)) == null ? void 0 : _a[0];
|
|
128
|
+
const targetLevelValue = LOG_LEVEL_VALUES[targetLevel];
|
|
129
|
+
return targetLevelValue >= highestLogLevelValue;
|
|
156
130
|
}
|
|
157
131
|
|
|
132
|
+
// packages/core/src/logger/utils/shared.utils.mts
|
|
133
|
+
var isUndefined = (obj) => typeof obj === "undefined";
|
|
134
|
+
var isObject = (fn) => !isNil(fn) && typeof fn === "object";
|
|
135
|
+
var isPlainObject = (fn) => {
|
|
136
|
+
if (!isObject(fn)) {
|
|
137
|
+
return false;
|
|
138
|
+
}
|
|
139
|
+
const proto = Object.getPrototypeOf(fn);
|
|
140
|
+
if (proto === null) {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
144
|
+
return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
145
|
+
};
|
|
146
|
+
var addLeadingSlash = (path) => path && typeof path === "string" ? path.charAt(0) !== "/" && path.substring(0, 2) !== "{/" ? "/" + path : path : "";
|
|
147
|
+
var normalizePath = (path) => path ? path.startsWith("/") ? ("/" + path.replace(/\/+$/, "")).replace(/\/+/g, "/") : "/" + path.replace(/\/+$/, "") : "/";
|
|
148
|
+
var stripEndSlash = (path) => path[path.length - 1] === "/" ? path.slice(0, path.length - 1) : path;
|
|
149
|
+
var isFunction = (val) => typeof val === "function";
|
|
150
|
+
var isString = (val) => typeof val === "string";
|
|
151
|
+
var isNumber = (val) => typeof val === "number";
|
|
152
|
+
var isConstructor = (val) => val === "constructor";
|
|
153
|
+
var isNil = (val) => isUndefined(val) || val === null;
|
|
154
|
+
var isEmpty = (array) => !(array && array.length > 0);
|
|
155
|
+
var isSymbol = (val) => typeof val === "symbol";
|
|
156
|
+
|
|
157
|
+
// packages/core/src/logger/console-logger.service.mts
|
|
158
|
+
import { inspect } from "util";
|
|
159
|
+
|
|
158
160
|
// packages/core/src/service-locator/enums/injectable-scope.enum.mts
|
|
159
161
|
var InjectableScope = /* @__PURE__ */ ((InjectableScope2) => {
|
|
160
162
|
InjectableScope2["Singleton"] = "Singleton";
|
|
@@ -713,7 +715,15 @@ var ServiceLocator = class {
|
|
|
713
715
|
).then(() => null);
|
|
714
716
|
}
|
|
715
717
|
makeInstanceName(token, args) {
|
|
716
|
-
let stringifiedArgs = args ? ":" + JSON.stringify(args
|
|
718
|
+
let stringifiedArgs = args ? ":" + JSON.stringify(args, (_, value) => {
|
|
719
|
+
if (typeof value === "function") {
|
|
720
|
+
return `function:${value.name}(${value.length})`;
|
|
721
|
+
}
|
|
722
|
+
if (typeof value === "symbol") {
|
|
723
|
+
return value.toString();
|
|
724
|
+
}
|
|
725
|
+
return value;
|
|
726
|
+
}).replaceAll(/"/g, "").replaceAll(/:/g, "=").replaceAll(/,/g, "|") : "";
|
|
717
727
|
const { name: name2 } = token;
|
|
718
728
|
if (typeof name2 === "function") {
|
|
719
729
|
const className = name2.name;
|
|
@@ -989,277 +999,362 @@ function override(token, target) {
|
|
|
989
999
|
};
|
|
990
1000
|
}
|
|
991
1001
|
|
|
992
|
-
// packages/core/src/
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
1002
|
+
// packages/core/src/logger/console-logger.service.mts
|
|
1003
|
+
var DEFAULT_DEPTH = 5;
|
|
1004
|
+
var DEFAULT_LOG_LEVELS = [
|
|
1005
|
+
"log",
|
|
1006
|
+
"error",
|
|
1007
|
+
"warn",
|
|
1008
|
+
"debug",
|
|
1009
|
+
"verbose",
|
|
1010
|
+
"fatal"
|
|
1011
|
+
];
|
|
1012
|
+
var dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
1013
|
+
year: "numeric",
|
|
1014
|
+
hour: "numeric",
|
|
1015
|
+
minute: "numeric",
|
|
1016
|
+
second: "numeric",
|
|
1017
|
+
day: "2-digit",
|
|
1018
|
+
month: "2-digit"
|
|
1019
|
+
});
|
|
1020
|
+
var _ConsoleLogger_decorators, _init;
|
|
1021
|
+
_ConsoleLogger_decorators = [Injectable()];
|
|
1022
|
+
var _ConsoleLogger = class _ConsoleLogger {
|
|
1023
|
+
/**
|
|
1024
|
+
* The options of the logger.
|
|
1025
|
+
*/
|
|
1026
|
+
options;
|
|
1027
|
+
/**
|
|
1028
|
+
* The context of the logger (can be set manually or automatically inferred).
|
|
1029
|
+
*/
|
|
1030
|
+
context;
|
|
1031
|
+
/**
|
|
1032
|
+
* The original context of the logger (set in the constructor).
|
|
1033
|
+
*/
|
|
1034
|
+
originalContext;
|
|
1035
|
+
/**
|
|
1036
|
+
* The options used for the "inspect" method.
|
|
1037
|
+
*/
|
|
1038
|
+
inspectOptions;
|
|
1039
|
+
/**
|
|
1040
|
+
* The last timestamp at which the log message was printed.
|
|
1041
|
+
*/
|
|
1042
|
+
static lastTimestampAt;
|
|
1043
|
+
constructor(contextOrOptions, options) {
|
|
1044
|
+
let [context, opts] = isString(contextOrOptions) ? [contextOrOptions, options] : options ? [void 0, options] : [contextOrOptions == null ? void 0 : contextOrOptions.context, contextOrOptions];
|
|
1045
|
+
opts = opts ?? {};
|
|
1046
|
+
opts.logLevels ??= DEFAULT_LOG_LEVELS;
|
|
1047
|
+
opts.colors ??= opts.colors ?? (opts.json ? false : true);
|
|
1048
|
+
opts.prefix ??= "Navios";
|
|
1049
|
+
this.options = opts;
|
|
1050
|
+
this.inspectOptions = this.getInspectOptions();
|
|
1051
|
+
if (context) {
|
|
1052
|
+
this.context = context;
|
|
1053
|
+
this.originalContext = context;
|
|
999
1054
|
}
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
for (const guard of Array.from(guards).reverse()) {
|
|
1005
|
-
controllerMetadata.guards.add(guard);
|
|
1006
|
-
}
|
|
1007
|
-
}
|
|
1008
|
-
}
|
|
1009
|
-
return Injectable({
|
|
1010
|
-
token,
|
|
1011
|
-
type: "Class" /* Class */,
|
|
1012
|
-
scope: "Instance" /* Instance */
|
|
1013
|
-
})(target, context);
|
|
1014
|
-
};
|
|
1015
|
-
}
|
|
1016
|
-
|
|
1017
|
-
// packages/core/src/decorators/endpoint.decorator.mts
|
|
1018
|
-
function Endpoint(endpoint) {
|
|
1019
|
-
return (target, context) => {
|
|
1020
|
-
if (typeof target !== "function") {
|
|
1021
|
-
throw new Error(
|
|
1022
|
-
"[Navios] Endpoint decorator can only be used on functions."
|
|
1023
|
-
);
|
|
1055
|
+
}
|
|
1056
|
+
log(message, ...optionalParams) {
|
|
1057
|
+
if (!this.isLevelEnabled("log")) {
|
|
1058
|
+
return;
|
|
1024
1059
|
}
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1060
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1061
|
+
message,
|
|
1062
|
+
...optionalParams
|
|
1063
|
+
]);
|
|
1064
|
+
this.printMessages(messages, context, "log");
|
|
1065
|
+
}
|
|
1066
|
+
error(message, ...optionalParams) {
|
|
1067
|
+
if (!this.isLevelEnabled("error")) {
|
|
1068
|
+
return;
|
|
1029
1069
|
}
|
|
1030
|
-
const
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
}
|
|
1038
|
-
endpointMetadata.config = config;
|
|
1039
|
-
endpointMetadata.classMethod = target.name;
|
|
1040
|
-
endpointMetadata.httpMethod = config.method;
|
|
1041
|
-
endpointMetadata.url = config.url;
|
|
1070
|
+
const { messages, context, stack } = this.getContextAndStackAndMessagesToPrint([message, ...optionalParams]);
|
|
1071
|
+
this.printMessages(messages, context, "error", "stderr", stack);
|
|
1072
|
+
this.printStackTrace(stack);
|
|
1073
|
+
}
|
|
1074
|
+
warn(message, ...optionalParams) {
|
|
1075
|
+
if (!this.isLevelEnabled("warn")) {
|
|
1076
|
+
return;
|
|
1042
1077
|
}
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
if (
|
|
1051
|
-
|
|
1078
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1079
|
+
message,
|
|
1080
|
+
...optionalParams
|
|
1081
|
+
]);
|
|
1082
|
+
this.printMessages(messages, context, "warn");
|
|
1083
|
+
}
|
|
1084
|
+
debug(message, ...optionalParams) {
|
|
1085
|
+
if (!this.isLevelEnabled("debug")) {
|
|
1086
|
+
return;
|
|
1052
1087
|
}
|
|
1053
|
-
const
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1088
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1089
|
+
message,
|
|
1090
|
+
...optionalParams
|
|
1091
|
+
]);
|
|
1092
|
+
this.printMessages(messages, context, "debug");
|
|
1093
|
+
}
|
|
1094
|
+
verbose(message, ...optionalParams) {
|
|
1095
|
+
if (!this.isLevelEnabled("verbose")) {
|
|
1096
|
+
return;
|
|
1059
1097
|
}
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1098
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1099
|
+
message,
|
|
1100
|
+
...optionalParams
|
|
1101
|
+
]);
|
|
1102
|
+
this.printMessages(messages, context, "verbose");
|
|
1103
|
+
}
|
|
1104
|
+
fatal(message, ...optionalParams) {
|
|
1105
|
+
if (!this.isLevelEnabled("fatal")) {
|
|
1106
|
+
return;
|
|
1064
1107
|
}
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1108
|
+
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1109
|
+
message,
|
|
1110
|
+
...optionalParams
|
|
1111
|
+
]);
|
|
1112
|
+
this.printMessages(messages, context, "fatal");
|
|
1113
|
+
}
|
|
1114
|
+
/**
|
|
1115
|
+
* Set log levels
|
|
1116
|
+
* @param levels log levels
|
|
1117
|
+
*/
|
|
1118
|
+
setLogLevels(levels) {
|
|
1119
|
+
if (!this.options) {
|
|
1120
|
+
this.options = {};
|
|
1069
1121
|
}
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1122
|
+
this.options.logLevels = levels;
|
|
1123
|
+
}
|
|
1124
|
+
/**
|
|
1125
|
+
* Set logger context
|
|
1126
|
+
* @param context context
|
|
1127
|
+
*/
|
|
1128
|
+
setContext(context) {
|
|
1129
|
+
this.context = context;
|
|
1130
|
+
}
|
|
1131
|
+
/**
|
|
1132
|
+
* Resets the logger context to the value that was passed in the constructor.
|
|
1133
|
+
*/
|
|
1134
|
+
resetContext() {
|
|
1135
|
+
this.context = this.originalContext;
|
|
1136
|
+
}
|
|
1137
|
+
isLevelEnabled(level) {
|
|
1138
|
+
var _a;
|
|
1139
|
+
const logLevels = (_a = this.options) == null ? void 0 : _a.logLevels;
|
|
1140
|
+
return isLogLevelEnabled(level, logLevels);
|
|
1141
|
+
}
|
|
1142
|
+
getTimestamp() {
|
|
1143
|
+
return dateTimeFormatter.format(Date.now());
|
|
1144
|
+
}
|
|
1145
|
+
printMessages(messages, context = "", logLevel = "log", writeStreamType, errorStack) {
|
|
1146
|
+
messages.forEach((message) => {
|
|
1147
|
+
if (this.options.json) {
|
|
1148
|
+
this.printAsJson(message, {
|
|
1149
|
+
context,
|
|
1150
|
+
logLevel,
|
|
1151
|
+
writeStreamType,
|
|
1152
|
+
errorStack
|
|
1153
|
+
});
|
|
1154
|
+
return;
|
|
1093
1155
|
}
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1156
|
+
const pidMessage = this.formatPid(process.pid);
|
|
1157
|
+
const contextMessage = this.formatContext(context);
|
|
1158
|
+
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
1159
|
+
const formattedLogLevel = logLevel.toUpperCase().padStart(7, " ");
|
|
1160
|
+
const formattedMessage = this.formatMessage(
|
|
1161
|
+
logLevel,
|
|
1162
|
+
message,
|
|
1163
|
+
pidMessage,
|
|
1164
|
+
formattedLogLevel,
|
|
1165
|
+
contextMessage,
|
|
1166
|
+
timestampDiff
|
|
1097
1167
|
);
|
|
1168
|
+
process[writeStreamType ?? "stdout"].write(formattedMessage);
|
|
1169
|
+
});
|
|
1170
|
+
}
|
|
1171
|
+
printAsJson(message, options) {
|
|
1172
|
+
const logObject = {
|
|
1173
|
+
level: options.logLevel,
|
|
1174
|
+
pid: process.pid,
|
|
1175
|
+
timestamp: Date.now(),
|
|
1176
|
+
message
|
|
1177
|
+
};
|
|
1178
|
+
if (options.context) {
|
|
1179
|
+
logObject.context = options.context;
|
|
1098
1180
|
}
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
}
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
constructor(statusCode, response, error) {
|
|
1106
|
-
this.statusCode = statusCode;
|
|
1107
|
-
this.response = response;
|
|
1108
|
-
this.error = error;
|
|
1181
|
+
if (options.errorStack) {
|
|
1182
|
+
logObject.stack = options.errorStack;
|
|
1183
|
+
}
|
|
1184
|
+
const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? JSON.stringify(logObject, this.stringifyReplacer) : inspect(logObject, this.inspectOptions);
|
|
1185
|
+
process[options.writeStreamType ?? "stdout"].write(`${formattedMessage}
|
|
1186
|
+
`);
|
|
1109
1187
|
}
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
// packages/core/src/exceptions/bad-request.exception.mts
|
|
1113
|
-
var BadRequestException = class extends HttpException {
|
|
1114
|
-
constructor(message) {
|
|
1115
|
-
super(400, message);
|
|
1188
|
+
formatPid(pid) {
|
|
1189
|
+
return `[${this.options.prefix}] ${pid} - `;
|
|
1116
1190
|
}
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1191
|
+
formatContext(context) {
|
|
1192
|
+
if (!context) {
|
|
1193
|
+
return "";
|
|
1194
|
+
}
|
|
1195
|
+
context = `[${context}] `;
|
|
1196
|
+
return this.options.colors ? yellow(context) : context;
|
|
1123
1197
|
}
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1198
|
+
formatMessage(logLevel, message, pidMessage, formattedLogLevel, contextMessage, timestampDiff) {
|
|
1199
|
+
const output = this.stringifyMessage(message, logLevel);
|
|
1200
|
+
pidMessage = this.colorize(pidMessage, logLevel);
|
|
1201
|
+
formattedLogLevel = this.colorize(formattedLogLevel, logLevel);
|
|
1202
|
+
return `${pidMessage}${this.getTimestamp()} ${formattedLogLevel} ${contextMessage}${output}${timestampDiff}
|
|
1203
|
+
`;
|
|
1130
1204
|
}
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1205
|
+
stringifyMessage(message, logLevel) {
|
|
1206
|
+
if (isFunction(message)) {
|
|
1207
|
+
const messageAsStr = Function.prototype.toString.call(message);
|
|
1208
|
+
const isClass = messageAsStr.startsWith("class ");
|
|
1209
|
+
if (isClass) {
|
|
1210
|
+
return this.stringifyMessage(message.name, logLevel);
|
|
1211
|
+
}
|
|
1212
|
+
return this.stringifyMessage(message(), logLevel);
|
|
1213
|
+
}
|
|
1214
|
+
if (typeof message === "string") {
|
|
1215
|
+
return this.colorize(message, logLevel);
|
|
1216
|
+
}
|
|
1217
|
+
const outputText = inspect(message, this.inspectOptions);
|
|
1218
|
+
if (isPlainObject(message)) {
|
|
1219
|
+
return `Object(${Object.keys(message).length}) ${outputText}`;
|
|
1220
|
+
}
|
|
1221
|
+
if (Array.isArray(message)) {
|
|
1222
|
+
return `Array(${message.length}) ${outputText}`;
|
|
1223
|
+
}
|
|
1224
|
+
return outputText;
|
|
1139
1225
|
}
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1226
|
+
colorize(message, logLevel) {
|
|
1227
|
+
if (!this.options.colors || this.options.json) {
|
|
1228
|
+
return message;
|
|
1229
|
+
}
|
|
1230
|
+
const color = this.getColorByLogLevel(logLevel);
|
|
1231
|
+
return color(message);
|
|
1146
1232
|
}
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1233
|
+
printStackTrace(stack) {
|
|
1234
|
+
if (!stack || this.options.json) {
|
|
1235
|
+
return;
|
|
1236
|
+
}
|
|
1237
|
+
process.stderr.write(`${stack}
|
|
1238
|
+
`);
|
|
1153
1239
|
}
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
);
|
|
1170
|
-
|
|
1171
|
-
// packages/core/src/logger/log-levels.mts
|
|
1172
|
-
var LOG_LEVELS = [
|
|
1173
|
-
"verbose",
|
|
1174
|
-
"debug",
|
|
1175
|
-
"log",
|
|
1176
|
-
"warn",
|
|
1177
|
-
"error",
|
|
1178
|
-
"fatal"
|
|
1179
|
-
];
|
|
1180
|
-
|
|
1181
|
-
// packages/core/src/logger/utils/is-log-level.util.mts
|
|
1182
|
-
function isLogLevel(maybeLogLevel) {
|
|
1183
|
-
return LOG_LEVELS.includes(maybeLogLevel);
|
|
1184
|
-
}
|
|
1185
|
-
|
|
1186
|
-
// packages/core/src/logger/utils/filter-log-levelts.util.mts
|
|
1187
|
-
function filterLogLevels(parseableString = "") {
|
|
1188
|
-
const sanitizedString = parseableString.replaceAll(" ", "").toLowerCase();
|
|
1189
|
-
if (sanitizedString[0] === ">") {
|
|
1190
|
-
const orEqual = sanitizedString[1] === "=";
|
|
1191
|
-
const logLevelIndex = LOG_LEVELS.indexOf(
|
|
1192
|
-
sanitizedString.substring(orEqual ? 2 : 1)
|
|
1193
|
-
);
|
|
1194
|
-
if (logLevelIndex === -1) {
|
|
1195
|
-
throw new Error(`parse error (unknown log level): ${sanitizedString}`);
|
|
1240
|
+
updateAndGetTimestampDiff() {
|
|
1241
|
+
var _a;
|
|
1242
|
+
const includeTimestamp = _ConsoleLogger.lastTimestampAt && ((_a = this.options) == null ? void 0 : _a.timestamp);
|
|
1243
|
+
const result = includeTimestamp ? this.formatTimestampDiff(Date.now() - _ConsoleLogger.lastTimestampAt) : "";
|
|
1244
|
+
_ConsoleLogger.lastTimestampAt = Date.now();
|
|
1245
|
+
return result;
|
|
1246
|
+
}
|
|
1247
|
+
formatTimestampDiff(timestampDiff) {
|
|
1248
|
+
const formattedDiff = ` +${timestampDiff}ms`;
|
|
1249
|
+
return this.options.colors ? yellow(formattedDiff) : formattedDiff;
|
|
1250
|
+
}
|
|
1251
|
+
getInspectOptions() {
|
|
1252
|
+
let breakLength = this.options.breakLength;
|
|
1253
|
+
if (typeof breakLength === "undefined") {
|
|
1254
|
+
breakLength = this.options.colors ? this.options.compact ? Infinity : void 0 : this.options.compact === false ? void 0 : Infinity;
|
|
1196
1255
|
}
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1256
|
+
const inspectOptions = {
|
|
1257
|
+
depth: this.options.depth ?? DEFAULT_DEPTH,
|
|
1258
|
+
sorted: this.options.sorted,
|
|
1259
|
+
showHidden: this.options.showHidden,
|
|
1260
|
+
compact: this.options.compact ?? (this.options.json ? true : false),
|
|
1261
|
+
colors: this.options.colors,
|
|
1262
|
+
breakLength
|
|
1263
|
+
};
|
|
1264
|
+
if (this.options.maxArrayLength) {
|
|
1265
|
+
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
|
1266
|
+
}
|
|
1267
|
+
if (this.options.maxStringLength) {
|
|
1268
|
+
inspectOptions.maxStringLength = this.options.maxStringLength;
|
|
1269
|
+
}
|
|
1270
|
+
return inspectOptions;
|
|
1271
|
+
}
|
|
1272
|
+
stringifyReplacer(key, value) {
|
|
1273
|
+
if (typeof value === "bigint") {
|
|
1274
|
+
return value.toString();
|
|
1275
|
+
}
|
|
1276
|
+
if (typeof value === "symbol") {
|
|
1277
|
+
return value.toString();
|
|
1278
|
+
}
|
|
1279
|
+
if (value instanceof Map || value instanceof Set || value instanceof Error) {
|
|
1280
|
+
return `${inspect(value, this.inspectOptions)}`;
|
|
1281
|
+
}
|
|
1282
|
+
return value;
|
|
1200
1283
|
}
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
var _a;
|
|
1215
|
-
if (!logLevels || Array.isArray(logLevels) && (logLevels == null ? void 0 : logLevels.length) === 0) {
|
|
1216
|
-
return false;
|
|
1284
|
+
getContextAndMessagesToPrint(args) {
|
|
1285
|
+
if ((args == null ? void 0 : args.length) <= 1) {
|
|
1286
|
+
return { messages: args, context: this.context };
|
|
1287
|
+
}
|
|
1288
|
+
const lastElement = args[args.length - 1];
|
|
1289
|
+
const isContext = isString(lastElement);
|
|
1290
|
+
if (!isContext) {
|
|
1291
|
+
return { messages: args, context: this.context };
|
|
1292
|
+
}
|
|
1293
|
+
return {
|
|
1294
|
+
context: lastElement,
|
|
1295
|
+
messages: args.slice(0, args.length - 1)
|
|
1296
|
+
};
|
|
1217
1297
|
}
|
|
1218
|
-
|
|
1219
|
-
|
|
1298
|
+
getContextAndStackAndMessagesToPrint(args) {
|
|
1299
|
+
if (args.length === 2) {
|
|
1300
|
+
return this.isStackFormat(args[1]) ? {
|
|
1301
|
+
messages: [args[0]],
|
|
1302
|
+
stack: args[1],
|
|
1303
|
+
context: this.context
|
|
1304
|
+
} : {
|
|
1305
|
+
messages: [args[0]],
|
|
1306
|
+
context: args[1]
|
|
1307
|
+
};
|
|
1308
|
+
}
|
|
1309
|
+
const { messages, context } = this.getContextAndMessagesToPrint(args);
|
|
1310
|
+
if ((messages == null ? void 0 : messages.length) <= 1) {
|
|
1311
|
+
return { messages, context };
|
|
1312
|
+
}
|
|
1313
|
+
const lastElement = messages[messages.length - 1];
|
|
1314
|
+
const isStack = isString(lastElement);
|
|
1315
|
+
if (!isStack && !isUndefined(lastElement)) {
|
|
1316
|
+
return { messages, context };
|
|
1317
|
+
}
|
|
1318
|
+
return {
|
|
1319
|
+
stack: lastElement,
|
|
1320
|
+
messages: messages.slice(0, messages.length - 1),
|
|
1321
|
+
context
|
|
1322
|
+
};
|
|
1220
1323
|
}
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
}
|
|
1225
|
-
|
|
1226
|
-
// packages/core/src/logger/utils/shared.utils.mts
|
|
1227
|
-
var isUndefined = (obj) => typeof obj === "undefined";
|
|
1228
|
-
var isObject = (fn) => !isNil(fn) && typeof fn === "object";
|
|
1229
|
-
var isPlainObject = (fn) => {
|
|
1230
|
-
if (!isObject(fn)) {
|
|
1231
|
-
return false;
|
|
1324
|
+
isStackFormat(stack) {
|
|
1325
|
+
if (!isString(stack) && !isUndefined(stack)) {
|
|
1326
|
+
return false;
|
|
1327
|
+
}
|
|
1328
|
+
return /^(.)+\n\s+at .+:\d+:\d+/.test(stack);
|
|
1232
1329
|
}
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1330
|
+
getColorByLogLevel(level) {
|
|
1331
|
+
switch (level) {
|
|
1332
|
+
case "debug":
|
|
1333
|
+
return clc.magentaBright;
|
|
1334
|
+
case "warn":
|
|
1335
|
+
return clc.yellow;
|
|
1336
|
+
case "error":
|
|
1337
|
+
return clc.red;
|
|
1338
|
+
case "verbose":
|
|
1339
|
+
return clc.cyanBright;
|
|
1340
|
+
case "fatal":
|
|
1341
|
+
return clc.bold;
|
|
1342
|
+
default:
|
|
1343
|
+
return clc.green;
|
|
1344
|
+
}
|
|
1236
1345
|
}
|
|
1237
|
-
const ctor = Object.prototype.hasOwnProperty.call(proto, "constructor") && proto.constructor;
|
|
1238
|
-
return typeof ctor === "function" && ctor instanceof ctor && Function.prototype.toString.call(ctor) === Function.prototype.toString.call(Object);
|
|
1239
1346
|
};
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
var
|
|
1244
|
-
var isString = (val) => typeof val === "string";
|
|
1245
|
-
var isNumber = (val) => typeof val === "number";
|
|
1246
|
-
var isConstructor = (val) => val === "constructor";
|
|
1247
|
-
var isNil = (val) => isUndefined(val) || val === null;
|
|
1248
|
-
var isEmpty = (array) => !(array && array.length > 0);
|
|
1249
|
-
var isSymbol = (val) => typeof val === "symbol";
|
|
1347
|
+
_init = __decoratorStart(null);
|
|
1348
|
+
_ConsoleLogger = __decorateElement(_init, 0, "ConsoleLogger", _ConsoleLogger_decorators, _ConsoleLogger);
|
|
1349
|
+
__runInitializers(_init, 1, _ConsoleLogger);
|
|
1350
|
+
var ConsoleLogger = _ConsoleLogger;
|
|
1250
1351
|
|
|
1251
|
-
// packages/core/src/logger/
|
|
1252
|
-
import {
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
"warn",
|
|
1258
|
-
"debug",
|
|
1259
|
-
"verbose",
|
|
1260
|
-
"fatal"
|
|
1261
|
-
];
|
|
1262
|
-
var dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
1352
|
+
// packages/core/src/logger/logger.factory.mts
|
|
1353
|
+
import { z } from "zod";
|
|
1354
|
+
|
|
1355
|
+
// packages/core/src/logger/logger.service.mts
|
|
1356
|
+
var DEFAULT_LOGGER = new ConsoleLogger();
|
|
1357
|
+
var dateTimeFormatter2 = new Intl.DateTimeFormat(void 0, {
|
|
1263
1358
|
year: "numeric",
|
|
1264
1359
|
hour: "numeric",
|
|
1265
1360
|
minute: "numeric",
|
|
@@ -1267,538 +1362,559 @@ var dateTimeFormatter = new Intl.DateTimeFormat(void 0, {
|
|
|
1267
1362
|
day: "2-digit",
|
|
1268
1363
|
month: "2-digit"
|
|
1269
1364
|
});
|
|
1270
|
-
var
|
|
1271
|
-
|
|
1272
|
-
var
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
options;
|
|
1277
|
-
/**
|
|
1278
|
-
* The context of the logger (can be set manually or automatically inferred).
|
|
1279
|
-
*/
|
|
1280
|
-
context;
|
|
1281
|
-
/**
|
|
1282
|
-
* The original context of the logger (set in the constructor).
|
|
1283
|
-
*/
|
|
1284
|
-
originalContext;
|
|
1285
|
-
/**
|
|
1286
|
-
* The options used for the "inspect" method.
|
|
1287
|
-
*/
|
|
1288
|
-
inspectOptions;
|
|
1289
|
-
/**
|
|
1290
|
-
* The last timestamp at which the log message was printed.
|
|
1291
|
-
*/
|
|
1292
|
-
static lastTimestampAt;
|
|
1293
|
-
constructor(contextOrOptions, options) {
|
|
1294
|
-
let [context, opts] = isString(contextOrOptions) ? [contextOrOptions, options] : options ? [void 0, options] : [contextOrOptions == null ? void 0 : contextOrOptions.context, contextOrOptions];
|
|
1295
|
-
opts = opts ?? {};
|
|
1296
|
-
opts.logLevels ??= DEFAULT_LOG_LEVELS;
|
|
1297
|
-
opts.colors ??= opts.colors ?? (opts.json ? false : true);
|
|
1298
|
-
opts.prefix ??= "Navios";
|
|
1299
|
-
this.options = opts;
|
|
1300
|
-
this.inspectOptions = this.getInspectOptions();
|
|
1301
|
-
if (context) {
|
|
1302
|
-
this.context = context;
|
|
1303
|
-
this.originalContext = context;
|
|
1304
|
-
}
|
|
1365
|
+
var _LoggerInstance_decorators, _init2;
|
|
1366
|
+
_LoggerInstance_decorators = [Injectable()];
|
|
1367
|
+
var _LoggerInstance = class _LoggerInstance {
|
|
1368
|
+
constructor(context, options = {}) {
|
|
1369
|
+
this.context = context;
|
|
1370
|
+
this.options = options;
|
|
1305
1371
|
}
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1372
|
+
static staticInstanceRef = DEFAULT_LOGGER;
|
|
1373
|
+
static logLevels;
|
|
1374
|
+
localInstanceRef;
|
|
1375
|
+
get localInstance() {
|
|
1376
|
+
if (_LoggerInstance.staticInstanceRef === DEFAULT_LOGGER) {
|
|
1377
|
+
return this.registerLocalInstanceRef();
|
|
1378
|
+
} else if (_LoggerInstance.staticInstanceRef instanceof _LoggerInstance) {
|
|
1379
|
+
const prototype = Object.getPrototypeOf(_LoggerInstance.staticInstanceRef);
|
|
1380
|
+
if (prototype.constructor === _LoggerInstance) {
|
|
1381
|
+
return this.registerLocalInstanceRef();
|
|
1382
|
+
}
|
|
1309
1383
|
}
|
|
1310
|
-
|
|
1311
|
-
message,
|
|
1312
|
-
...optionalParams
|
|
1313
|
-
]);
|
|
1314
|
-
this.printMessages(messages, context, "log");
|
|
1384
|
+
return _LoggerInstance.staticInstanceRef;
|
|
1315
1385
|
}
|
|
1316
1386
|
error(message, ...optionalParams) {
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
this.
|
|
1322
|
-
|
|
1387
|
+
var _a;
|
|
1388
|
+
optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(
|
|
1389
|
+
this.context
|
|
1390
|
+
) : optionalParams;
|
|
1391
|
+
(_a = this.localInstance) == null ? void 0 : _a.error(message, ...optionalParams);
|
|
1392
|
+
}
|
|
1393
|
+
log(message, ...optionalParams) {
|
|
1394
|
+
var _a;
|
|
1395
|
+
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1396
|
+
(_a = this.localInstance) == null ? void 0 : _a.log(message, ...optionalParams);
|
|
1323
1397
|
}
|
|
1324
1398
|
warn(message, ...optionalParams) {
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1329
|
-
message,
|
|
1330
|
-
...optionalParams
|
|
1331
|
-
]);
|
|
1332
|
-
this.printMessages(messages, context, "warn");
|
|
1399
|
+
var _a;
|
|
1400
|
+
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1401
|
+
(_a = this.localInstance) == null ? void 0 : _a.warn(message, ...optionalParams);
|
|
1333
1402
|
}
|
|
1334
1403
|
debug(message, ...optionalParams) {
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1339
|
-
message,
|
|
1340
|
-
...optionalParams
|
|
1341
|
-
]);
|
|
1342
|
-
this.printMessages(messages, context, "debug");
|
|
1404
|
+
var _a, _b;
|
|
1405
|
+
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1406
|
+
(_b = (_a = this.localInstance) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1343
1407
|
}
|
|
1344
1408
|
verbose(message, ...optionalParams) {
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1349
|
-
message,
|
|
1350
|
-
...optionalParams
|
|
1351
|
-
]);
|
|
1352
|
-
this.printMessages(messages, context, "verbose");
|
|
1353
|
-
}
|
|
1354
|
-
fatal(message, ...optionalParams) {
|
|
1355
|
-
if (!this.isLevelEnabled("fatal")) {
|
|
1356
|
-
return;
|
|
1357
|
-
}
|
|
1358
|
-
const { messages, context } = this.getContextAndMessagesToPrint([
|
|
1359
|
-
message,
|
|
1360
|
-
...optionalParams
|
|
1361
|
-
]);
|
|
1362
|
-
this.printMessages(messages, context, "fatal");
|
|
1363
|
-
}
|
|
1364
|
-
/**
|
|
1365
|
-
* Set log levels
|
|
1366
|
-
* @param levels log levels
|
|
1367
|
-
*/
|
|
1368
|
-
setLogLevels(levels) {
|
|
1369
|
-
if (!this.options) {
|
|
1370
|
-
this.options = {};
|
|
1371
|
-
}
|
|
1372
|
-
this.options.logLevels = levels;
|
|
1409
|
+
var _a, _b;
|
|
1410
|
+
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1411
|
+
(_b = (_a = this.localInstance) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1373
1412
|
}
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
setContext(context) {
|
|
1379
|
-
this.context = context;
|
|
1413
|
+
fatal(message, ...optionalParams) {
|
|
1414
|
+
var _a, _b;
|
|
1415
|
+
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1416
|
+
(_b = (_a = this.localInstance) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1380
1417
|
}
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
resetContext() {
|
|
1385
|
-
this.context = this.originalContext;
|
|
1418
|
+
static error(message, ...optionalParams) {
|
|
1419
|
+
var _a;
|
|
1420
|
+
(_a = this.staticInstanceRef) == null ? void 0 : _a.error(message, ...optionalParams);
|
|
1386
1421
|
}
|
|
1387
|
-
|
|
1422
|
+
static log(message, ...optionalParams) {
|
|
1388
1423
|
var _a;
|
|
1389
|
-
|
|
1390
|
-
return isLogLevelEnabled(level, logLevels);
|
|
1424
|
+
(_a = this.staticInstanceRef) == null ? void 0 : _a.log(message, ...optionalParams);
|
|
1391
1425
|
}
|
|
1392
|
-
|
|
1393
|
-
|
|
1426
|
+
static warn(message, ...optionalParams) {
|
|
1427
|
+
var _a;
|
|
1428
|
+
(_a = this.staticInstanceRef) == null ? void 0 : _a.warn(message, ...optionalParams);
|
|
1394
1429
|
}
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
this.printAsJson(message, {
|
|
1399
|
-
context,
|
|
1400
|
-
logLevel,
|
|
1401
|
-
writeStreamType,
|
|
1402
|
-
errorStack
|
|
1403
|
-
});
|
|
1404
|
-
return;
|
|
1405
|
-
}
|
|
1406
|
-
const pidMessage = this.formatPid(process.pid);
|
|
1407
|
-
const contextMessage = this.formatContext(context);
|
|
1408
|
-
const timestampDiff = this.updateAndGetTimestampDiff();
|
|
1409
|
-
const formattedLogLevel = logLevel.toUpperCase().padStart(7, " ");
|
|
1410
|
-
const formattedMessage = this.formatMessage(
|
|
1411
|
-
logLevel,
|
|
1412
|
-
message,
|
|
1413
|
-
pidMessage,
|
|
1414
|
-
formattedLogLevel,
|
|
1415
|
-
contextMessage,
|
|
1416
|
-
timestampDiff
|
|
1417
|
-
);
|
|
1418
|
-
process[writeStreamType ?? "stdout"].write(formattedMessage);
|
|
1419
|
-
});
|
|
1430
|
+
static debug(message, ...optionalParams) {
|
|
1431
|
+
var _a, _b;
|
|
1432
|
+
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1420
1433
|
}
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1434
|
+
static verbose(message, ...optionalParams) {
|
|
1435
|
+
var _a, _b;
|
|
1436
|
+
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1437
|
+
}
|
|
1438
|
+
static fatal(message, ...optionalParams) {
|
|
1439
|
+
var _a, _b;
|
|
1440
|
+
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1441
|
+
}
|
|
1442
|
+
static getTimestamp() {
|
|
1443
|
+
return dateTimeFormatter2.format(Date.now());
|
|
1444
|
+
}
|
|
1445
|
+
static overrideLogger(logger) {
|
|
1446
|
+
var _a, _b;
|
|
1447
|
+
console.log(logger);
|
|
1448
|
+
if (Array.isArray(logger)) {
|
|
1449
|
+
_LoggerInstance.logLevels = logger;
|
|
1450
|
+
return (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.setLogLevels) == null ? void 0 : _b.call(_a, logger);
|
|
1430
1451
|
}
|
|
1431
|
-
if (
|
|
1432
|
-
|
|
1452
|
+
if (isObject(logger)) {
|
|
1453
|
+
this.staticInstanceRef = logger;
|
|
1454
|
+
} else {
|
|
1455
|
+
this.staticInstanceRef = void 0;
|
|
1433
1456
|
}
|
|
1434
|
-
const formattedMessage = !this.options.colors && this.inspectOptions.compact === true ? JSON.stringify(logObject, this.stringifyReplacer) : inspect(logObject, this.inspectOptions);
|
|
1435
|
-
process[options.writeStreamType ?? "stdout"].write(`${formattedMessage}
|
|
1436
|
-
`);
|
|
1437
1457
|
}
|
|
1438
|
-
|
|
1439
|
-
|
|
1458
|
+
static isLevelEnabled(level) {
|
|
1459
|
+
const logLevels = _LoggerInstance.logLevels;
|
|
1460
|
+
return isLogLevelEnabled(level, logLevels);
|
|
1440
1461
|
}
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1462
|
+
registerLocalInstanceRef() {
|
|
1463
|
+
var _a;
|
|
1464
|
+
if (this.localInstanceRef) {
|
|
1465
|
+
return this.localInstanceRef;
|
|
1444
1466
|
}
|
|
1445
|
-
|
|
1446
|
-
|
|
1467
|
+
this.localInstanceRef = new ConsoleLogger(this.context, {
|
|
1468
|
+
timestamp: (_a = this.options) == null ? void 0 : _a.timestamp,
|
|
1469
|
+
logLevels: _LoggerInstance.logLevels
|
|
1470
|
+
});
|
|
1471
|
+
return this.localInstanceRef;
|
|
1447
1472
|
}
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1473
|
+
};
|
|
1474
|
+
_init2 = __decoratorStart(null);
|
|
1475
|
+
_LoggerInstance = __decorateElement(_init2, 0, "LoggerInstance", _LoggerInstance_decorators, _LoggerInstance);
|
|
1476
|
+
__runInitializers(_init2, 1, _LoggerInstance);
|
|
1477
|
+
var LoggerInstance = _LoggerInstance;
|
|
1478
|
+
|
|
1479
|
+
// packages/core/src/logger/logger.factory.mts
|
|
1480
|
+
var LoggerInjectionToken = "LoggerInjectionToken";
|
|
1481
|
+
var LoggerOptions = z.object({
|
|
1482
|
+
context: z.string().optional(),
|
|
1483
|
+
options: z.object({
|
|
1484
|
+
timestamp: z.boolean().optional()
|
|
1485
|
+
}).optional()
|
|
1486
|
+
}).optional();
|
|
1487
|
+
var Logger = InjectionToken.create(LoggerInjectionToken, LoggerOptions);
|
|
1488
|
+
var _LoggerFactory_decorators, _init3;
|
|
1489
|
+
_LoggerFactory_decorators = [Injectable({
|
|
1490
|
+
type: "Factory" /* Factory */,
|
|
1491
|
+
token: Logger
|
|
1492
|
+
})];
|
|
1493
|
+
var LoggerFactory = class {
|
|
1494
|
+
create(ctx, args) {
|
|
1495
|
+
return new LoggerInstance(args == null ? void 0 : args.context, args == null ? void 0 : args.options);
|
|
1454
1496
|
}
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
if (typeof message === "string") {
|
|
1465
|
-
return this.colorize(message, logLevel);
|
|
1466
|
-
}
|
|
1467
|
-
const outputText = inspect(message, this.inspectOptions);
|
|
1468
|
-
if (isPlainObject(message)) {
|
|
1469
|
-
return `Object(${Object.keys(message).length}) ${outputText}`;
|
|
1470
|
-
}
|
|
1471
|
-
if (Array.isArray(message)) {
|
|
1472
|
-
return `Array(${message.length}) ${outputText}`;
|
|
1473
|
-
}
|
|
1474
|
-
return outputText;
|
|
1497
|
+
};
|
|
1498
|
+
_init3 = __decoratorStart(null);
|
|
1499
|
+
LoggerFactory = __decorateElement(_init3, 0, "LoggerFactory", _LoggerFactory_decorators, LoggerFactory);
|
|
1500
|
+
__runInitializers(_init3, 1, LoggerFactory);
|
|
1501
|
+
|
|
1502
|
+
// packages/core/src/logger/pino-wrapper.mts
|
|
1503
|
+
var PinoWrapper = class _PinoWrapper {
|
|
1504
|
+
constructor(logger) {
|
|
1505
|
+
this.logger = logger;
|
|
1475
1506
|
}
|
|
1476
|
-
|
|
1477
|
-
if (
|
|
1478
|
-
return message;
|
|
1507
|
+
fatal(message, ...optionalParams) {
|
|
1508
|
+
if (this.logger.fatal === void 0) {
|
|
1509
|
+
return this.error(message, ...optionalParams);
|
|
1479
1510
|
}
|
|
1480
|
-
|
|
1481
|
-
return color(message);
|
|
1511
|
+
this.logger.fatal(message, ...optionalParams);
|
|
1482
1512
|
}
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
return;
|
|
1486
|
-
}
|
|
1487
|
-
process.stderr.write(`${stack}
|
|
1488
|
-
`);
|
|
1513
|
+
error(message, ...optionalParams) {
|
|
1514
|
+
this.logger.error(message, ...optionalParams);
|
|
1489
1515
|
}
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
const includeTimestamp = _ConsoleLogger.lastTimestampAt && ((_a = this.options) == null ? void 0 : _a.timestamp);
|
|
1493
|
-
const result = includeTimestamp ? this.formatTimestampDiff(Date.now() - _ConsoleLogger.lastTimestampAt) : "";
|
|
1494
|
-
_ConsoleLogger.lastTimestampAt = Date.now();
|
|
1495
|
-
return result;
|
|
1516
|
+
warn(message, ...optionalParams) {
|
|
1517
|
+
this.logger.warn(message, ...optionalParams);
|
|
1496
1518
|
}
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
return this.options.colors ? yellow(formattedDiff) : formattedDiff;
|
|
1519
|
+
info(message, ...optionalParams) {
|
|
1520
|
+
this.logger.log(message, ...optionalParams);
|
|
1500
1521
|
}
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1522
|
+
debug(message, ...optionalParams) {
|
|
1523
|
+
var _a, _b;
|
|
1524
|
+
(_b = (_a = this.logger).debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1525
|
+
}
|
|
1526
|
+
trace(message, ...optionalParams) {
|
|
1527
|
+
var _a, _b;
|
|
1528
|
+
(_b = (_a = this.logger).verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1529
|
+
}
|
|
1530
|
+
silent(message, ...optionalParams) {
|
|
1531
|
+
}
|
|
1532
|
+
child(options) {
|
|
1533
|
+
const keys = Object.keys(options);
|
|
1534
|
+
let newContext = this.logger["context"] ?? "";
|
|
1535
|
+
if (keys.length > 1) {
|
|
1536
|
+
newContext = `${this.logger["context"] ?? ""}:${JSON.stringify(options)}`;
|
|
1505
1537
|
}
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
if (this.options.maxArrayLength) {
|
|
1515
|
-
inspectOptions.maxArrayLength = this.options.maxArrayLength;
|
|
1538
|
+
return new _PinoWrapper(
|
|
1539
|
+
// @ts-expect-error We don't need to support this in the current version
|
|
1540
|
+
new LoggerInstance(newContext, this.logger["options"])
|
|
1541
|
+
);
|
|
1542
|
+
}
|
|
1543
|
+
get level() {
|
|
1544
|
+
if ("level" in this.logger && this.logger.level) {
|
|
1545
|
+
return this.logger.level;
|
|
1516
1546
|
}
|
|
1517
|
-
|
|
1518
|
-
|
|
1547
|
+
const levels = LoggerInstance["logLevels"];
|
|
1548
|
+
if (levels) {
|
|
1549
|
+
return levels[0];
|
|
1519
1550
|
}
|
|
1520
|
-
return
|
|
1551
|
+
return "info";
|
|
1521
1552
|
}
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1553
|
+
};
|
|
1554
|
+
|
|
1555
|
+
// packages/core/src/config/config.service.mts
|
|
1556
|
+
import { NaviosException } from "@navios/common";
|
|
1557
|
+
var ConfigServiceInstance = class {
|
|
1558
|
+
constructor(config = {}, logger) {
|
|
1559
|
+
this.config = config;
|
|
1560
|
+
this.logger = logger;
|
|
1561
|
+
}
|
|
1562
|
+
getConfig() {
|
|
1563
|
+
return this.config;
|
|
1564
|
+
}
|
|
1565
|
+
get(key) {
|
|
1566
|
+
var _a, _b;
|
|
1567
|
+
try {
|
|
1568
|
+
const parts = String(key).split(".");
|
|
1569
|
+
let value = this.config;
|
|
1570
|
+
for (const part of parts) {
|
|
1571
|
+
if (value === null || value === void 0 || typeof value !== "object") {
|
|
1572
|
+
return null;
|
|
1573
|
+
}
|
|
1574
|
+
value = value[part];
|
|
1575
|
+
}
|
|
1576
|
+
return value ?? null;
|
|
1577
|
+
} catch (error) {
|
|
1578
|
+
(_b = (_a = this.logger).debug) == null ? void 0 : _b.call(
|
|
1579
|
+
_a,
|
|
1580
|
+
`Failed to get config value for key ${String(key)}`,
|
|
1581
|
+
error
|
|
1582
|
+
);
|
|
1583
|
+
return null;
|
|
1528
1584
|
}
|
|
1529
|
-
|
|
1530
|
-
|
|
1585
|
+
}
|
|
1586
|
+
getOrDefault(key, defaultValue) {
|
|
1587
|
+
const value = this.get(key);
|
|
1588
|
+
return value !== null ? value : defaultValue;
|
|
1589
|
+
}
|
|
1590
|
+
getOrThrow(key, errorMessage) {
|
|
1591
|
+
const value = this.get(key);
|
|
1592
|
+
if (value === null) {
|
|
1593
|
+
const message = errorMessage || `Configuration value for key "${String(key)}" is not defined`;
|
|
1594
|
+
this.logger.error(message);
|
|
1595
|
+
throw new NaviosException(message);
|
|
1531
1596
|
}
|
|
1532
1597
|
return value;
|
|
1533
1598
|
}
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1599
|
+
};
|
|
1600
|
+
|
|
1601
|
+
// packages/core/src/config/config.provider.mts
|
|
1602
|
+
var ConfigProviderInjectionToken = "ConfigProvider";
|
|
1603
|
+
var ConfigProviderOptions = z2.object({
|
|
1604
|
+
load: z2.function()
|
|
1605
|
+
});
|
|
1606
|
+
var ConfigProvider = InjectionToken.create(ConfigProviderInjectionToken, ConfigProviderOptions);
|
|
1607
|
+
var _ConfigProviderFactory_decorators, _init4;
|
|
1608
|
+
_ConfigProviderFactory_decorators = [Injectable({
|
|
1609
|
+
token: ConfigProvider,
|
|
1610
|
+
type: "Factory" /* Factory */
|
|
1611
|
+
})];
|
|
1612
|
+
var ConfigProviderFactory = class {
|
|
1613
|
+
logger = inject(Logger, {
|
|
1614
|
+
context: "ConfigService"
|
|
1615
|
+
});
|
|
1616
|
+
async create(ctx, args) {
|
|
1617
|
+
const { load } = args;
|
|
1618
|
+
const logger = await this.logger;
|
|
1619
|
+
try {
|
|
1620
|
+
const config = await load();
|
|
1621
|
+
return new ConfigServiceInstance(config, logger);
|
|
1622
|
+
} catch (error) {
|
|
1623
|
+
logger.error("Error loading config", error);
|
|
1624
|
+
throw error;
|
|
1542
1625
|
}
|
|
1543
|
-
return {
|
|
1544
|
-
context: lastElement,
|
|
1545
|
-
messages: args.slice(0, args.length - 1)
|
|
1546
|
-
};
|
|
1547
1626
|
}
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1627
|
+
};
|
|
1628
|
+
_init4 = __decoratorStart(null);
|
|
1629
|
+
ConfigProviderFactory = __decorateElement(_init4, 0, "ConfigProviderFactory", _ConfigProviderFactory_decorators, ConfigProviderFactory);
|
|
1630
|
+
__runInitializers(_init4, 1, ConfigProviderFactory);
|
|
1631
|
+
function makeConfigToken(options) {
|
|
1632
|
+
var _ConfigServiceImpl_decorators, _init9;
|
|
1633
|
+
_ConfigServiceImpl_decorators = [Injectable({
|
|
1634
|
+
type: "Factory" /* Factory */
|
|
1635
|
+
})];
|
|
1636
|
+
class ConfigServiceImpl {
|
|
1637
|
+
configService = inject(ConfigProvider, options);
|
|
1638
|
+
create() {
|
|
1639
|
+
return this.configService;
|
|
1640
|
+
}
|
|
1641
|
+
}
|
|
1642
|
+
_init9 = __decoratorStart(null);
|
|
1643
|
+
ConfigServiceImpl = __decorateElement(_init9, 0, "ConfigServiceImpl", _ConfigServiceImpl_decorators, ConfigServiceImpl);
|
|
1644
|
+
__runInitializers(_init9, 1, ConfigServiceImpl);
|
|
1645
|
+
return getInjectableToken(ConfigServiceImpl);
|
|
1646
|
+
}
|
|
1647
|
+
|
|
1648
|
+
// packages/core/src/metadata/endpoint.metadata.mts
|
|
1649
|
+
var EndpointMetadataKey = Symbol("EndpointMetadataKey");
|
|
1650
|
+
function getAllEndpointMetadata(context) {
|
|
1651
|
+
if (context.metadata) {
|
|
1652
|
+
const metadata = context.metadata[EndpointMetadataKey];
|
|
1653
|
+
if (metadata) {
|
|
1654
|
+
return metadata;
|
|
1655
|
+
} else {
|
|
1656
|
+
context.metadata[EndpointMetadataKey] = /* @__PURE__ */ new Set();
|
|
1657
|
+
return context.metadata[EndpointMetadataKey];
|
|
1562
1658
|
}
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1659
|
+
}
|
|
1660
|
+
throw new Error("[Navios] Wrong environment.");
|
|
1661
|
+
}
|
|
1662
|
+
function getEndpointMetadata(target, context) {
|
|
1663
|
+
if (context.metadata) {
|
|
1664
|
+
const metadata = getAllEndpointMetadata(context);
|
|
1665
|
+
if (metadata) {
|
|
1666
|
+
const endpointMetadata = Array.from(metadata).find(
|
|
1667
|
+
(item) => item.classMethod === target.name
|
|
1668
|
+
);
|
|
1669
|
+
if (endpointMetadata) {
|
|
1670
|
+
return endpointMetadata;
|
|
1671
|
+
} else {
|
|
1672
|
+
const newMetadata = {
|
|
1673
|
+
classMethod: target.name,
|
|
1674
|
+
url: "",
|
|
1675
|
+
httpMethod: "GET",
|
|
1676
|
+
config: null,
|
|
1677
|
+
guards: /* @__PURE__ */ new Set(),
|
|
1678
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
1679
|
+
};
|
|
1680
|
+
metadata.add(newMetadata);
|
|
1681
|
+
return newMetadata;
|
|
1682
|
+
}
|
|
1567
1683
|
}
|
|
1568
|
-
return {
|
|
1569
|
-
stack: lastElement,
|
|
1570
|
-
messages: messages.slice(0, messages.length - 1),
|
|
1571
|
-
context
|
|
1572
|
-
};
|
|
1573
1684
|
}
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1685
|
+
throw new Error("[Navios] Wrong environment.");
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
// packages/core/src/metadata/controller.metadata.mts
|
|
1689
|
+
var ControllerMetadataKey = Symbol("ControllerMetadataKey");
|
|
1690
|
+
function getControllerMetadata(target, context) {
|
|
1691
|
+
if (context.metadata) {
|
|
1692
|
+
const metadata = context.metadata[ControllerMetadataKey];
|
|
1693
|
+
if (metadata) {
|
|
1694
|
+
return metadata;
|
|
1695
|
+
} else {
|
|
1696
|
+
const endpointsMetadata = getAllEndpointMetadata(context);
|
|
1697
|
+
const newMetadata = {
|
|
1698
|
+
endpoints: endpointsMetadata,
|
|
1699
|
+
guards: /* @__PURE__ */ new Set(),
|
|
1700
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
1701
|
+
};
|
|
1702
|
+
context.metadata[ControllerMetadataKey] = newMetadata;
|
|
1703
|
+
target[ControllerMetadataKey] = newMetadata;
|
|
1704
|
+
return newMetadata;
|
|
1577
1705
|
}
|
|
1578
|
-
return /^(.)+\n\s+at .+:\d+:\d+/.test(stack);
|
|
1579
1706
|
}
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1707
|
+
throw new Error("[Navios] Wrong environment.");
|
|
1708
|
+
}
|
|
1709
|
+
function extractControllerMetadata(target) {
|
|
1710
|
+
const metadata = target[ControllerMetadataKey];
|
|
1711
|
+
if (!metadata) {
|
|
1712
|
+
throw new Error(
|
|
1713
|
+
"[Navios] Controller metadata not found. Make sure to use @Controller decorator."
|
|
1714
|
+
);
|
|
1715
|
+
}
|
|
1716
|
+
return metadata;
|
|
1717
|
+
}
|
|
1718
|
+
function hasControllerMetadata(target) {
|
|
1719
|
+
const metadata = target[ControllerMetadataKey];
|
|
1720
|
+
return !!metadata;
|
|
1721
|
+
}
|
|
1722
|
+
|
|
1723
|
+
// packages/core/src/metadata/module.metadata.mts
|
|
1724
|
+
var ModuleMetadataKey = Symbol("ControllerMetadataKey");
|
|
1725
|
+
function getModuleMetadata(target, context) {
|
|
1726
|
+
if (context.metadata) {
|
|
1727
|
+
const metadata = context.metadata[ModuleMetadataKey];
|
|
1728
|
+
if (metadata) {
|
|
1729
|
+
return metadata;
|
|
1730
|
+
} else {
|
|
1731
|
+
const newMetadata = {
|
|
1732
|
+
controllers: /* @__PURE__ */ new Set(),
|
|
1733
|
+
imports: /* @__PURE__ */ new Set(),
|
|
1734
|
+
guards: /* @__PURE__ */ new Set(),
|
|
1735
|
+
customAttributes: /* @__PURE__ */ new Map()
|
|
1736
|
+
};
|
|
1737
|
+
context.metadata[ModuleMetadataKey] = newMetadata;
|
|
1738
|
+
target[ModuleMetadataKey] = newMetadata;
|
|
1739
|
+
return newMetadata;
|
|
1594
1740
|
}
|
|
1595
1741
|
}
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1742
|
+
throw new Error("[Navios] Wrong environment.");
|
|
1743
|
+
}
|
|
1744
|
+
function extractModuleMetadata(target) {
|
|
1745
|
+
const metadata = target[ModuleMetadataKey];
|
|
1746
|
+
if (!metadata) {
|
|
1747
|
+
throw new Error(
|
|
1748
|
+
"[Navios] Module metadata not found. Make sure to use @Module decorator."
|
|
1749
|
+
);
|
|
1750
|
+
}
|
|
1751
|
+
return metadata;
|
|
1752
|
+
}
|
|
1753
|
+
function hasModuleMetadata(target) {
|
|
1754
|
+
return !!target[ModuleMetadataKey];
|
|
1755
|
+
}
|
|
1601
1756
|
|
|
1602
|
-
// packages/core/src/
|
|
1603
|
-
|
|
1757
|
+
// packages/core/src/decorators/controller.decorator.mts
|
|
1758
|
+
function Controller({ guards } = {}) {
|
|
1759
|
+
return function(target, context) {
|
|
1760
|
+
if (context.kind !== "class") {
|
|
1761
|
+
throw new Error(
|
|
1762
|
+
"[Navios] @Controller decorator can only be used on classes."
|
|
1763
|
+
);
|
|
1764
|
+
}
|
|
1765
|
+
const token = InjectionToken.create(target);
|
|
1766
|
+
if (context.metadata) {
|
|
1767
|
+
const controllerMetadata = getControllerMetadata(target, context);
|
|
1768
|
+
if (guards) {
|
|
1769
|
+
for (const guard of Array.from(guards).reverse()) {
|
|
1770
|
+
controllerMetadata.guards.add(guard);
|
|
1771
|
+
}
|
|
1772
|
+
}
|
|
1773
|
+
}
|
|
1774
|
+
return Injectable({
|
|
1775
|
+
token,
|
|
1776
|
+
type: "Class" /* Class */,
|
|
1777
|
+
scope: "Instance" /* Instance */
|
|
1778
|
+
})(target, context);
|
|
1779
|
+
};
|
|
1780
|
+
}
|
|
1604
1781
|
|
|
1605
|
-
// packages/core/src/
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1782
|
+
// packages/core/src/decorators/endpoint.decorator.mts
|
|
1783
|
+
function Endpoint(endpoint) {
|
|
1784
|
+
return (target, context) => {
|
|
1785
|
+
if (typeof target !== "function") {
|
|
1786
|
+
throw new Error(
|
|
1787
|
+
"[Navios] Endpoint decorator can only be used on functions."
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
if (context.kind !== "method") {
|
|
1791
|
+
throw new Error(
|
|
1792
|
+
"[Navios] Endpoint decorator can only be used on methods."
|
|
1793
|
+
);
|
|
1794
|
+
}
|
|
1795
|
+
const config = endpoint.config;
|
|
1796
|
+
if (context.metadata) {
|
|
1797
|
+
let endpointMetadata = getEndpointMetadata(target, context);
|
|
1798
|
+
if (endpointMetadata.config && endpointMetadata.config.url) {
|
|
1799
|
+
throw new Error(
|
|
1800
|
+
`[Navios] Endpoint ${config.method} ${config.url} already exists. Please use a different method or url.`
|
|
1801
|
+
);
|
|
1802
|
+
}
|
|
1803
|
+
endpointMetadata.config = config;
|
|
1804
|
+
endpointMetadata.classMethod = target.name;
|
|
1805
|
+
endpointMetadata.httpMethod = config.method;
|
|
1806
|
+
endpointMetadata.url = config.url;
|
|
1807
|
+
}
|
|
1808
|
+
return target;
|
|
1809
|
+
};
|
|
1810
|
+
}
|
|
1811
|
+
|
|
1812
|
+
// packages/core/src/decorators/module.decorator.mts
|
|
1813
|
+
function Module(metadata) {
|
|
1814
|
+
return (target, context) => {
|
|
1815
|
+
if (context.kind !== "class") {
|
|
1816
|
+
throw new Error("[Navios] @Module decorator can only be used on classes.");
|
|
1817
|
+
}
|
|
1818
|
+
const token = InjectionToken.create(target);
|
|
1819
|
+
const moduleMetadata = getModuleMetadata(target, context);
|
|
1820
|
+
if (metadata.controllers) {
|
|
1821
|
+
for (const controller of metadata.controllers) {
|
|
1822
|
+
moduleMetadata.controllers.add(controller);
|
|
1632
1823
|
}
|
|
1633
1824
|
}
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
optionalParams = this.context ? (optionalParams.length ? optionalParams : [void 0]).concat(
|
|
1639
|
-
this.context
|
|
1640
|
-
) : optionalParams;
|
|
1641
|
-
(_a = this.localInstance) == null ? void 0 : _a.error(message, ...optionalParams);
|
|
1642
|
-
}
|
|
1643
|
-
log(message, ...optionalParams) {
|
|
1644
|
-
var _a;
|
|
1645
|
-
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1646
|
-
(_a = this.localInstance) == null ? void 0 : _a.log(message, ...optionalParams);
|
|
1647
|
-
}
|
|
1648
|
-
warn(message, ...optionalParams) {
|
|
1649
|
-
var _a;
|
|
1650
|
-
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1651
|
-
(_a = this.localInstance) == null ? void 0 : _a.warn(message, ...optionalParams);
|
|
1652
|
-
}
|
|
1653
|
-
debug(message, ...optionalParams) {
|
|
1654
|
-
var _a, _b;
|
|
1655
|
-
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1656
|
-
(_b = (_a = this.localInstance) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1657
|
-
}
|
|
1658
|
-
verbose(message, ...optionalParams) {
|
|
1659
|
-
var _a, _b;
|
|
1660
|
-
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1661
|
-
(_b = (_a = this.localInstance) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1662
|
-
}
|
|
1663
|
-
fatal(message, ...optionalParams) {
|
|
1664
|
-
var _a, _b;
|
|
1665
|
-
optionalParams = this.context ? optionalParams.concat(this.context) : optionalParams;
|
|
1666
|
-
(_b = (_a = this.localInstance) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1667
|
-
}
|
|
1668
|
-
static error(message, ...optionalParams) {
|
|
1669
|
-
var _a;
|
|
1670
|
-
(_a = this.staticInstanceRef) == null ? void 0 : _a.error(message, ...optionalParams);
|
|
1671
|
-
}
|
|
1672
|
-
static log(message, ...optionalParams) {
|
|
1673
|
-
var _a;
|
|
1674
|
-
(_a = this.staticInstanceRef) == null ? void 0 : _a.log(message, ...optionalParams);
|
|
1675
|
-
}
|
|
1676
|
-
static warn(message, ...optionalParams) {
|
|
1677
|
-
var _a;
|
|
1678
|
-
(_a = this.staticInstanceRef) == null ? void 0 : _a.warn(message, ...optionalParams);
|
|
1679
|
-
}
|
|
1680
|
-
static debug(message, ...optionalParams) {
|
|
1681
|
-
var _a, _b;
|
|
1682
|
-
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1683
|
-
}
|
|
1684
|
-
static verbose(message, ...optionalParams) {
|
|
1685
|
-
var _a, _b;
|
|
1686
|
-
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.verbose) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1687
|
-
}
|
|
1688
|
-
static fatal(message, ...optionalParams) {
|
|
1689
|
-
var _a, _b;
|
|
1690
|
-
(_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.fatal) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1691
|
-
}
|
|
1692
|
-
static getTimestamp() {
|
|
1693
|
-
return dateTimeFormatter2.format(Date.now());
|
|
1694
|
-
}
|
|
1695
|
-
static overrideLogger(logger) {
|
|
1696
|
-
var _a, _b;
|
|
1697
|
-
console.log(logger);
|
|
1698
|
-
if (Array.isArray(logger)) {
|
|
1699
|
-
_LoggerInstance.logLevels = logger;
|
|
1700
|
-
return (_b = (_a = this.staticInstanceRef) == null ? void 0 : _a.setLogLevels) == null ? void 0 : _b.call(_a, logger);
|
|
1825
|
+
if (metadata.imports) {
|
|
1826
|
+
for (const importedModule of metadata.imports) {
|
|
1827
|
+
moduleMetadata.imports.add(importedModule);
|
|
1828
|
+
}
|
|
1701
1829
|
}
|
|
1702
|
-
if (
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1830
|
+
if (metadata.guards) {
|
|
1831
|
+
for (const guard of Array.from(metadata.guards).reverse()) {
|
|
1832
|
+
moduleMetadata.guards.add(guard);
|
|
1833
|
+
}
|
|
1706
1834
|
}
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1835
|
+
return Injectable({
|
|
1836
|
+
token,
|
|
1837
|
+
type: "Class" /* Class */,
|
|
1838
|
+
scope: "Singleton" /* Singleton */
|
|
1839
|
+
})(target, context);
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
|
|
1843
|
+
// packages/core/src/decorators/use-guards.decorator.mts
|
|
1844
|
+
function UseGuards(...guards) {
|
|
1845
|
+
return function(target, context) {
|
|
1846
|
+
if (context.kind === "class") {
|
|
1847
|
+
const controllerMetadata = getControllerMetadata(
|
|
1848
|
+
target,
|
|
1849
|
+
context
|
|
1850
|
+
);
|
|
1851
|
+
for (const guard of guards.reverse()) {
|
|
1852
|
+
controllerMetadata.guards.add(guard);
|
|
1853
|
+
}
|
|
1854
|
+
} else if (context.kind === "method") {
|
|
1855
|
+
const endpointMetadata = getEndpointMetadata(target, context);
|
|
1856
|
+
for (const guard of guards.reverse()) {
|
|
1857
|
+
endpointMetadata.guards.add(guard);
|
|
1858
|
+
}
|
|
1859
|
+
} else {
|
|
1860
|
+
throw new Error(
|
|
1861
|
+
"[Navios] @UseGuards decorator can only be used on classes or methods."
|
|
1862
|
+
);
|
|
1716
1863
|
}
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1864
|
+
return target;
|
|
1865
|
+
};
|
|
1866
|
+
}
|
|
1867
|
+
|
|
1868
|
+
// packages/core/src/exceptions/http.exception.mts
|
|
1869
|
+
var HttpException = class {
|
|
1870
|
+
constructor(statusCode, response, error) {
|
|
1871
|
+
this.statusCode = statusCode;
|
|
1872
|
+
this.response = response;
|
|
1873
|
+
this.error = error;
|
|
1722
1874
|
}
|
|
1723
1875
|
};
|
|
1724
|
-
_init2 = __decoratorStart(null);
|
|
1725
|
-
_LoggerInstance = __decorateElement(_init2, 0, "LoggerInstance", _LoggerInstance_decorators, _LoggerInstance);
|
|
1726
|
-
__runInitializers(_init2, 1, _LoggerInstance);
|
|
1727
|
-
var LoggerInstance = _LoggerInstance;
|
|
1728
1876
|
|
|
1729
|
-
// packages/core/src/
|
|
1730
|
-
var
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
options: z.object({
|
|
1734
|
-
timestamp: z.boolean().optional()
|
|
1735
|
-
}).optional()
|
|
1736
|
-
}).optional();
|
|
1737
|
-
var Logger = InjectionToken.create(LoggerInjectionToken, LoggerOptions);
|
|
1738
|
-
var _LoggerFactory_decorators, _init3;
|
|
1739
|
-
_LoggerFactory_decorators = [Injectable({
|
|
1740
|
-
type: "Factory" /* Factory */,
|
|
1741
|
-
token: Logger
|
|
1742
|
-
})];
|
|
1743
|
-
var LoggerFactory = class {
|
|
1744
|
-
create(ctx, args) {
|
|
1745
|
-
return new LoggerInstance(args == null ? void 0 : args.context, args == null ? void 0 : args.options);
|
|
1877
|
+
// packages/core/src/exceptions/bad-request.exception.mts
|
|
1878
|
+
var BadRequestException = class extends HttpException {
|
|
1879
|
+
constructor(message) {
|
|
1880
|
+
super(400, message);
|
|
1746
1881
|
}
|
|
1747
1882
|
};
|
|
1748
|
-
_init3 = __decoratorStart(null);
|
|
1749
|
-
LoggerFactory = __decorateElement(_init3, 0, "LoggerFactory", _LoggerFactory_decorators, LoggerFactory);
|
|
1750
|
-
__runInitializers(_init3, 1, LoggerFactory);
|
|
1751
1883
|
|
|
1752
|
-
// packages/core/src/
|
|
1753
|
-
var
|
|
1754
|
-
constructor(
|
|
1755
|
-
|
|
1756
|
-
}
|
|
1757
|
-
fatal(message, ...optionalParams) {
|
|
1758
|
-
if (this.logger.fatal === void 0) {
|
|
1759
|
-
return this.error(message, ...optionalParams);
|
|
1760
|
-
}
|
|
1761
|
-
this.logger.fatal(message, ...optionalParams);
|
|
1762
|
-
}
|
|
1763
|
-
error(message, ...optionalParams) {
|
|
1764
|
-
this.logger.error(message, ...optionalParams);
|
|
1765
|
-
}
|
|
1766
|
-
warn(message, ...optionalParams) {
|
|
1767
|
-
this.logger.warn(message, ...optionalParams);
|
|
1768
|
-
}
|
|
1769
|
-
info(message, ...optionalParams) {
|
|
1770
|
-
this.logger.log(message, ...optionalParams);
|
|
1771
|
-
}
|
|
1772
|
-
debug(message, ...optionalParams) {
|
|
1773
|
-
var _a, _b;
|
|
1774
|
-
(_b = (_a = this.logger).debug) == null ? void 0 : _b.call(_a, message, ...optionalParams);
|
|
1884
|
+
// packages/core/src/exceptions/forbidden.exception.mts
|
|
1885
|
+
var ForbiddenException = class extends HttpException {
|
|
1886
|
+
constructor(message) {
|
|
1887
|
+
super(403, message);
|
|
1775
1888
|
}
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1889
|
+
};
|
|
1890
|
+
|
|
1891
|
+
// packages/core/src/exceptions/internal-server-error.exception.mts
|
|
1892
|
+
var InternalServerErrorException = class extends HttpException {
|
|
1893
|
+
constructor(message, error) {
|
|
1894
|
+
super(500, message, error);
|
|
1779
1895
|
}
|
|
1780
|
-
|
|
1896
|
+
};
|
|
1897
|
+
|
|
1898
|
+
// packages/core/src/exceptions/not-found.exception.mts
|
|
1899
|
+
var NotFoundException = class extends HttpException {
|
|
1900
|
+
constructor(response, error) {
|
|
1901
|
+
super(404, response, error);
|
|
1902
|
+
this.response = response;
|
|
1903
|
+
this.error = error;
|
|
1781
1904
|
}
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
return new _PinoWrapper(
|
|
1789
|
-
// @ts-expect-error We don't need to support this in the current version
|
|
1790
|
-
new LoggerInstance(newContext, this.logger["options"])
|
|
1791
|
-
);
|
|
1905
|
+
};
|
|
1906
|
+
|
|
1907
|
+
// packages/core/src/exceptions/unauthorized.exception.mts
|
|
1908
|
+
var UnauthorizedException = class extends HttpException {
|
|
1909
|
+
constructor(message, error) {
|
|
1910
|
+
super(401, message, error);
|
|
1792
1911
|
}
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
return levels[0];
|
|
1800
|
-
}
|
|
1801
|
-
return "info";
|
|
1912
|
+
};
|
|
1913
|
+
|
|
1914
|
+
// packages/core/src/exceptions/conflict.exception.mts
|
|
1915
|
+
var ConflictException = class extends HttpException {
|
|
1916
|
+
constructor(message, error) {
|
|
1917
|
+
super(409, message, error);
|
|
1802
1918
|
}
|
|
1803
1919
|
};
|
|
1804
1920
|
|
|
@@ -1867,7 +1983,7 @@ var ExecutionContext2 = class {
|
|
|
1867
1983
|
};
|
|
1868
1984
|
|
|
1869
1985
|
// packages/core/src/services/guard-runner.service.mts
|
|
1870
|
-
var _GuardRunnerService_decorators,
|
|
1986
|
+
var _GuardRunnerService_decorators, _init5;
|
|
1871
1987
|
_GuardRunnerService_decorators = [Injectable()];
|
|
1872
1988
|
var GuardRunnerService = class {
|
|
1873
1989
|
async runGuards(allGuards, executionContext) {
|
|
@@ -1930,12 +2046,12 @@ var GuardRunnerService = class {
|
|
|
1930
2046
|
return guards;
|
|
1931
2047
|
}
|
|
1932
2048
|
};
|
|
1933
|
-
|
|
1934
|
-
GuardRunnerService = __decorateElement(
|
|
1935
|
-
__runInitializers(
|
|
2049
|
+
_init5 = __decoratorStart(null);
|
|
2050
|
+
GuardRunnerService = __decorateElement(_init5, 0, "GuardRunnerService", _GuardRunnerService_decorators, GuardRunnerService);
|
|
2051
|
+
__runInitializers(_init5, 1, GuardRunnerService);
|
|
1936
2052
|
|
|
1937
2053
|
// packages/core/src/services/controller-adapter.service.mts
|
|
1938
|
-
var _ControllerAdapterService_decorators,
|
|
2054
|
+
var _ControllerAdapterService_decorators, _init6;
|
|
1939
2055
|
_ControllerAdapterService_decorators = [Injectable()];
|
|
1940
2056
|
var _ControllerAdapterService = class _ControllerAdapterService {
|
|
1941
2057
|
guardRunner = syncInject(GuardRunnerService);
|
|
@@ -2042,13 +2158,13 @@ var _ControllerAdapterService = class _ControllerAdapterService {
|
|
|
2042
2158
|
}
|
|
2043
2159
|
}
|
|
2044
2160
|
};
|
|
2045
|
-
|
|
2046
|
-
_ControllerAdapterService = __decorateElement(
|
|
2047
|
-
__runInitializers(
|
|
2161
|
+
_init6 = __decoratorStart(null);
|
|
2162
|
+
_ControllerAdapterService = __decorateElement(_init6, 0, "ControllerAdapterService", _ControllerAdapterService_decorators, _ControllerAdapterService);
|
|
2163
|
+
__runInitializers(_init6, 1, _ControllerAdapterService);
|
|
2048
2164
|
var ControllerAdapterService = _ControllerAdapterService;
|
|
2049
2165
|
|
|
2050
2166
|
// packages/core/src/services/module-loader.service.mts
|
|
2051
|
-
var _ModuleLoaderService_decorators,
|
|
2167
|
+
var _ModuleLoaderService_decorators, _init7;
|
|
2052
2168
|
_ModuleLoaderService_decorators = [Injectable()];
|
|
2053
2169
|
var _ModuleLoaderService = class _ModuleLoaderService {
|
|
2054
2170
|
logger = syncInject(Logger, {
|
|
@@ -2105,9 +2221,9 @@ var _ModuleLoaderService = class _ModuleLoaderService {
|
|
|
2105
2221
|
return this.modulesMetadata;
|
|
2106
2222
|
}
|
|
2107
2223
|
};
|
|
2108
|
-
|
|
2109
|
-
_ModuleLoaderService = __decorateElement(
|
|
2110
|
-
__runInitializers(
|
|
2224
|
+
_init7 = __decoratorStart(null);
|
|
2225
|
+
_ModuleLoaderService = __decorateElement(_init7, 0, "ModuleLoaderService", _ModuleLoaderService_decorators, _ModuleLoaderService);
|
|
2226
|
+
__runInitializers(_init7, 1, _ModuleLoaderService);
|
|
2111
2227
|
var ModuleLoaderService = _ModuleLoaderService;
|
|
2112
2228
|
|
|
2113
2229
|
// packages/core/src/attribute.factory.mts
|
|
@@ -2174,7 +2290,7 @@ import {
|
|
|
2174
2290
|
serializerCompiler,
|
|
2175
2291
|
validatorCompiler
|
|
2176
2292
|
} from "fastify-type-provider-zod";
|
|
2177
|
-
var _NaviosApplication_decorators,
|
|
2293
|
+
var _NaviosApplication_decorators, _init8;
|
|
2178
2294
|
_NaviosApplication_decorators = [Injectable()];
|
|
2179
2295
|
var _NaviosApplication = class _NaviosApplication {
|
|
2180
2296
|
moduleLoader = syncInject(ModuleLoaderService);
|
|
@@ -2279,9 +2395,9 @@ var _NaviosApplication = class _NaviosApplication {
|
|
|
2279
2395
|
await this.server.listen(options);
|
|
2280
2396
|
}
|
|
2281
2397
|
};
|
|
2282
|
-
|
|
2283
|
-
_NaviosApplication = __decorateElement(
|
|
2284
|
-
__runInitializers(
|
|
2398
|
+
_init8 = __decoratorStart(null);
|
|
2399
|
+
_NaviosApplication = __decorateElement(_init8, 0, "NaviosApplication", _NaviosApplication_decorators, _NaviosApplication);
|
|
2400
|
+
__runInitializers(_init8, 1, _NaviosApplication);
|
|
2285
2401
|
var NaviosApplication = _NaviosApplication;
|
|
2286
2402
|
|
|
2287
2403
|
// packages/core/src/navios.factory.mts
|
|
@@ -2306,6 +2422,11 @@ export {
|
|
|
2306
2422
|
Application,
|
|
2307
2423
|
AttributeFactory,
|
|
2308
2424
|
BadRequestException,
|
|
2425
|
+
ConfigProvider,
|
|
2426
|
+
ConfigProviderFactory,
|
|
2427
|
+
ConfigProviderInjectionToken,
|
|
2428
|
+
ConfigProviderOptions,
|
|
2429
|
+
ConfigServiceInstance,
|
|
2309
2430
|
ConflictException,
|
|
2310
2431
|
ConsoleLogger,
|
|
2311
2432
|
Controller,
|
|
@@ -2356,6 +2477,8 @@ export {
|
|
|
2356
2477
|
UseGuards,
|
|
2357
2478
|
addLeadingSlash,
|
|
2358
2479
|
clc,
|
|
2480
|
+
envInt,
|
|
2481
|
+
envString,
|
|
2359
2482
|
extractControllerMetadata,
|
|
2360
2483
|
extractModuleMetadata,
|
|
2361
2484
|
filterLogLevels,
|
|
@@ -2380,6 +2503,7 @@ export {
|
|
|
2380
2503
|
isString,
|
|
2381
2504
|
isSymbol,
|
|
2382
2505
|
isUndefined,
|
|
2506
|
+
makeConfigToken,
|
|
2383
2507
|
normalizePath,
|
|
2384
2508
|
override,
|
|
2385
2509
|
provideServiceLocator,
|