koatty 3.11.9 → 3.13.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,45 +1,55 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2025-01-14 16:20:07
3
+ * @Date: 2025-04-19 23:06:49
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
- 'use strict';
9
-
10
- var koatty_config = require('koatty_config');
11
- var koatty_container = require('koatty_container');
12
- var koatty_core = require('koatty_core');
13
- var koatty_exception = require('koatty_exception');
14
- var koatty_lib = require('koatty_lib');
15
- var koatty_router = require('koatty_router');
16
- var koatty_logger = require('koatty_logger');
17
- var koatty_loader = require('koatty_loader');
18
- var koatty_serve = require('koatty_serve');
19
- var path = require('path');
20
-
21
- function _interopNamespaceDefault(e) {
22
- var n = Object.create(null);
23
- if (e) {
24
- Object.keys(e).forEach(function (k) {
25
- if (k !== 'default') {
26
- var d = Object.getOwnPropertyDescriptor(e, k);
27
- Object.defineProperty(n, k, d.get ? d : {
28
- enumerable: true,
29
- get: function () { return e[k]; }
30
- });
31
- }
32
- });
33
- }
34
- n.default = e;
35
- return Object.freeze(n);
8
+ "use strict";
9
+
10
+ var e = require("koatty_config");
11
+
12
+ var t = require("koatty_container");
13
+
14
+ var o = require("koatty_core");
15
+
16
+ var r = require("koatty_exception");
17
+
18
+ var a = require("koatty_lib");
19
+
20
+ var n = require("koatty_router");
21
+
22
+ var s = require("koatty_logger");
23
+
24
+ var i = require("koatty_loader");
25
+
26
+ var l = require("koatty_serve");
27
+
28
+ var c = require("path");
29
+
30
+ function p(e) {
31
+ var t = Object.create(null);
32
+ if (e) Object.keys(e).forEach((function(o) {
33
+ if (o !== "default") {
34
+ var r = Object.getOwnPropertyDescriptor(e, o);
35
+ Object.defineProperty(t, o, r.get ? r : {
36
+ enumerable: !0,
37
+ get: function() {
38
+ return e[o];
39
+ }
40
+ });
41
+ }
42
+ }));
43
+ t.default = e;
44
+ return Object.freeze(t);
36
45
  }
37
46
 
38
- var path__namespace = /*#__PURE__*/_interopNamespaceDefault(path);
47
+ var f = p(c);
48
+
49
+ var d = "3.13.0";
39
50
 
40
- var version = "3.11.9";
41
- var engines = {
42
- node: ">12.0.0"
51
+ var u = {
52
+ node: ">12.0.0"
43
53
  };
44
54
 
45
55
  /*
@@ -50,31 +60,16 @@ var engines = {
50
60
  * @LastEditTime: 2024-10-31 17:52:43
51
61
  * @License: BSD (3-Clause)
52
62
  * @Copyright (c): <richenlin(at)gmail.com>
53
- */
54
- // Logger
55
- const Logger = koatty_logger.DefaultLogger;
56
- /**
57
- * SetLogger
58
- *
59
- * @export
60
- * @param {{
61
- * logLevel?: LogLevelType;
62
- * logFilePath?: string;
63
- * sensFields?: string[];
64
- * }} config
65
- */
66
- function SetLogger(app, config) {
67
- if (config.logLevel) {
68
- koatty_logger.DefaultLogger.setLevel(config.logLevel);
69
- }
70
- if (config.logFilePath && !app.silent) {
71
- koatty_lib.Helper.define(app, "logsPath", config.logFilePath);
72
- process.env.LOGS_PATH = config.logFilePath;
73
- koatty_logger.DefaultLogger.setLogFilePath(config.logFilePath);
74
- }
75
- if (config.sensFields) {
76
- koatty_logger.DefaultLogger.setSensFields(config.sensFields);
77
- }
63
+ */ const g = s.DefaultLogger;
64
+
65
+ function h(e, t) {
66
+ if (t.logLevel) s.DefaultLogger.setLevel(t.logLevel);
67
+ if (t.logFilePath && !e.silent) {
68
+ a.Helper.define(e, "logsPath", t.logFilePath);
69
+ process.env.LOGS_PATH = t.logFilePath;
70
+ s.DefaultLogger.setLogFilePath(t.logFilePath);
71
+ }
72
+ if (t.sensFields) s.DefaultLogger.setSensFields(t.sensFields);
78
73
  }
79
74
 
80
75
  /*
@@ -85,75 +80,39 @@ function SetLogger(app, config) {
85
80
  * @LastEditTime: 2025-01-14 16:14:10
86
81
  * @License: BSD (3-Clause)
87
82
  * @Copyright (c): <richenlin(at)gmail.com>
88
- */
89
- const KOATTY_VERSION = version;
90
- const ENGINES_VERSION = engines.node.slice(1) || '12.0.0';
91
- /**
92
- * Check class file
93
- * name should be always the same as class name
94
- * class must be unique
95
- *
96
- * @export
97
- * @param {string} fileName
98
- * @param {string} xpath
99
- * @param {*} target
100
- * @param {Set<unknown>} [exSet]
101
- * @returns {*}
102
- */
103
- function checkClass(fileName, xpath, target, exSet) {
104
- if (koatty_lib.Helper.isClass(target) && target.name != fileName) { // export default class name{}
105
- throw Error(`The file(${xpath}) name should be always the same as class name.`);
106
- }
107
- if (target["__esModule"]) {
108
- if (target.name === undefined) { // export class name{}
109
- const keys = Object.keys(target);
110
- if (keys[0] != fileName && koatty_lib.Helper.isClass(target[keys[0]])) {
111
- throw Error(`The file(${xpath}) name should be always the same as class name.`);
112
- }
113
- }
114
- else if (target.name != fileName) { // export default class {}
115
- throw Error(`The file(${xpath}) name should be always the same as class name.`);
116
- }
117
- }
118
- if (!exSet) {
119
- return;
120
- }
121
- if (exSet.has(fileName)) {
122
- throw new Error(`A same class already exists. at \`${xpath}\`.`);
123
- }
124
- exSet.add(fileName);
125
- return;
83
+ */ const y = d;
84
+
85
+ const C = u.node.slice(1) || "12.0.0";
86
+
87
+ function m(e, t, o, r) {
88
+ if (a.Helper.isClass(o) && o.name != e) throw Error(`The file(${t}) name should be always the same as class name.`);
89
+ if (o["__esModule"]) if (o.name === void 0) {
90
+ const r = Object.keys(o);
91
+ if (r[0] != e && a.Helper.isClass(o[r[0]])) throw Error(`The file(${t}) name should be always the same as class name.`);
92
+ } else if (o.name != e) throw Error(`The file(${t}) name should be always the same as class name.`);
93
+ if (!r) return;
94
+ if (r.has(e)) throw new Error(`A same class already exists. at \`${t}\`.`);
95
+ r.add(e);
96
+ return;
126
97
  }
127
- /**
128
- * check node version
129
- * @return {void} []
130
- */
131
- function checkRuntime() {
132
- let nodeEngines = ENGINES_VERSION;
133
- nodeEngines = nodeEngines.slice(0, nodeEngines.lastIndexOf('.'));
134
- let nodeVersion = process.version;
135
- if (nodeVersion[0] === 'v') {
136
- nodeVersion = nodeVersion.slice(1);
137
- }
138
- nodeVersion = nodeVersion.slice(0, nodeVersion.lastIndexOf('.'));
139
- if (koatty_lib.Helper.toNumber(nodeEngines) > koatty_lib.Helper.toNumber(nodeVersion)) {
140
- Logger.Error(`Koatty need node version > ${nodeEngines}, current version is ${nodeVersion}, please upgrade it.`);
141
- process.exit(-1);
142
- }
98
+
99
+ function L() {
100
+ let e = C;
101
+ e = e.slice(0, e.lastIndexOf("."));
102
+ let t = process.version;
103
+ if (t[0] === "v") t = t.slice(1);
104
+ t = t.slice(0, t.lastIndexOf("."));
105
+ if (a.Helper.toNumber(e) > a.Helper.toNumber(t)) {
106
+ g.Error(`Koatty need node version > ${e}, current version is ${t}, please upgrade it.`);
107
+ process.exit(-1);
108
+ }
143
109
  }
144
- /**
145
- * unittest running environment detection
146
- * only support jest
147
- * @returns {boolean}
148
- */
149
- const checkUTRuntime = () => {
150
- let isUTRuntime = false;
151
- // UT运行环境判断,暂时先只判断jest
152
- const argv = JSON.stringify(process.argv[1]);
153
- if (argv.indexOf('jest') > -1) {
154
- isUTRuntime = true;
155
- }
156
- return isUTRuntime;
110
+
111
+ const v = () => {
112
+ let e = !1;
113
+ const t = JSON.stringify(process.argv[1]);
114
+ if (t.indexOf("jest") > -1) e = !0;
115
+ return e;
157
116
  };
158
117
 
159
118
  /*
@@ -164,442 +123,282 @@ const checkUTRuntime = () => {
164
123
  * @LastEditTime: 2023-12-09 23:00:13
165
124
  * @License: BSD (3-Clause)
166
125
  * @Copyright (c): <richenlin(at)gmail.com>
167
- */
168
- const COMPONENT_SCAN = 'COMPONENT_SCAN';
169
- const CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
170
- // tslint:disable: no-irregular-whitespace
171
- const LOGO = `
172
-
173
- ┬┌─┌─┐┌─┐┌┬┐┌┬┐┬ ┬
174
- ├┴┐│ │├─┤ │ │ └┬┘
175
- ┴ ┴└─┘┴ ┴ ┴ ┴ ┴
176
- -------------------------------------------
177
- https://github.com/koatty
178
- `;
126
+ */ const E = "COMPONENT_SCAN";
127
+
128
+ const O = "CONFIGURATION_SCAN";
179
129
 
130
+ const w = `\n\n┬┌─┌─┐┌─┐┌┬┐┌┬┐┬ ┬\n├┴┐│ │├─┤ │ │ └┬┘\n┴ ┴└─┘┴ ┴ ┴ ┴ ┴ \n-------------------------------------------\nhttps://github.com/koatty\n`
180
131
  /*
181
132
  * @Description: framework loader
182
133
  * @Usage:
183
134
  * @Author: richen
184
135
  * @Date: 2023-12-09 22:55:49
185
- * @LastEditTime: 2025-01-14 16:12:59
136
+ * @LastEditTime: 2025-03-13 16:44:39
186
137
  * @License: BSD (3-Clause)
187
138
  * @Copyright (c): <richenlin(at)gmail.com>
188
- */
189
- /**
190
- *
191
- */
139
+ */;
140
+
192
141
  class Loader {
193
- /**
194
- * Creates an instance of Loader.
195
- * @param {KoattyApplication} app
196
- * @memberof Loader
197
- */
198
- constructor(app) {
199
- this.app = app;
200
- }
201
- /**
202
- * initialize env
203
- *
204
- * @static
205
- * @param {KoattyApplication} app
206
- * @memberof Loader
207
- */
208
- static initialize(app) {
209
- if (app.env == 'development') {
210
- Logger.setLevel("debug");
211
- }
212
- else {
213
- Logger.setLevel("info");
214
- }
215
- // define path
216
- const rootPath = app.rootPath || process.cwd();
217
- const appPath = app.appPath || path__namespace.resolve(rootPath, app.appDebug ? 'src' : 'dist');
218
- const koattyPath = path__namespace.resolve(__dirname, '..');
219
- koatty_lib.Helper.define(app, 'rootPath', rootPath);
220
- koatty_lib.Helper.define(app, 'appPath', appPath);
221
- koatty_lib.Helper.define(app, 'koattyPath', koattyPath);
222
- //
223
- if (koatty_lib.Helper.isEmpty(app.name)) {
224
- const pkg = koatty_lib.Helper.safeRequire(`${path__namespace.dirname(appPath)}/package.json`);
225
- if (pkg.name) {
226
- app.name = pkg.name;
227
- app.version = app.version || pkg.version;
228
- }
229
- }
230
- process.env.ROOT_PATH = rootPath;
231
- process.env.APP_PATH = appPath;
232
- process.env.KOATTY_PATH = koattyPath;
233
- // Compatible with old version, will be deprecated
234
- koatty_lib.Helper.define(app, 'thinkPath', koattyPath);
235
- process.env.THINK_PATH = koattyPath;
236
- }
237
- /**
238
- * Get component metadata
239
- *
240
- * @static
241
- * @param {KoattyApplication} app
242
- * @param {*} target
243
- * @returns {*} {any[]}
244
- * @memberof Loader
245
- */
246
- static GetComponentMeta(app, target) {
247
- let componentMetas = [];
248
- const componentMeta = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, COMPONENT_SCAN, target);
249
- if (componentMeta) {
250
- if (koatty_lib.Helper.isArray(componentMeta)) {
251
- componentMetas = componentMeta;
252
- }
253
- else {
254
- componentMetas.push(componentMeta);
255
- }
256
- }
257
- if (componentMetas.length < 1) {
258
- componentMetas = [app.appPath];
259
- }
260
- return componentMetas;
261
- }
262
- /**
263
- * Get configuration metadata
264
- *
265
- * @static
266
- * @param {KoattyApplication} app
267
- * @param {*} target
268
- * @returns {*} {any[]}
269
- * @memberof Loader
270
- */
271
- static GetConfigurationMeta(app, target) {
272
- const confMeta = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, CONFIGURATION_SCAN, target);
273
- let configurationMetas = [];
274
- if (confMeta) {
275
- if (koatty_lib.Helper.isArray(confMeta)) {
276
- configurationMetas = confMeta;
277
- }
278
- else {
279
- configurationMetas.push(confMeta);
280
- }
281
- }
282
- return configurationMetas;
283
- }
284
- /**
285
- * Load all bean, excepted config/*、App.ts
286
- *
287
- * @static
288
- * @param {KoattyApplication} app
289
- * @param {*} target
290
- * @memberof Loader
291
- */
292
- static CheckAllComponents(app, target) {
293
- // component metadata
294
- const componentMetas = Loader.GetComponentMeta(app, target);
295
- // configuration metadata
296
- const configurationMetas = Loader.GetConfigurationMeta(app, target);
297
- const exSet = new Set();
298
- koatty_loader.Load(componentMetas, '', (fileName, xpath, xTarget) => {
299
- checkClass(fileName, xpath, xTarget, exSet);
300
- }, ['**/**.js', '**/**.ts', '!**/**.d.ts'], [...configurationMetas, `${target.name || '.no'}.ts`]);
301
- exSet.clear();
302
- }
303
- /**
304
- * Set Logger level
305
- *
306
- * @static
307
- * @param {KoattyApplication} app
308
- * @memberof Loader
309
- */
310
- static SetLogger(app) {
311
- const data = app.getMetaData('_configs') || [];
312
- const configs = data[0] || {};
313
- //Logger
314
- if (configs.config) {
315
- const opt = configs.config;
316
- let logLevel = "debug", logFilePath = "", sensFields = [];
317
- if (app.env === "production") {
318
- logLevel = "info";
319
- }
320
- if (opt.logs_level) {
321
- logLevel = (opt.logs_level).toLowerCase();
322
- }
323
- if (opt.logs_path) {
324
- logFilePath = opt.logs_path;
325
- }
326
- if (opt.sens_fields) {
327
- sensFields = opt.sens_fields;
328
- }
329
- SetLogger(app, { logLevel, logFilePath, sensFields });
330
- }
142
+ constructor(e) {
143
+ this.app = e;
144
+ }
145
+ static initialize(e) {
146
+ if (e.env == "development") g.setLevel("debug"); else g.setLevel("info");
147
+ const t = e.rootPath || process.cwd();
148
+ const o = e.appPath || f.resolve(t, e.appDebug ? "src" : "dist");
149
+ const r = f.resolve(__dirname, "..");
150
+ a.Helper.define(e, "rootPath", t);
151
+ a.Helper.define(e, "appPath", o);
152
+ a.Helper.define(e, "koattyPath", r);
153
+ if (a.Helper.isEmpty(e.name)) {
154
+ const t = a.Helper.safeRequire(`${f.dirname(o)}/package.json`);
155
+ if (t.name) {
156
+ e.name = t.name;
157
+ e.version = e.version || t.version;
158
+ }
331
159
  }
332
- /**
333
- * Load app event hook funcs
334
- *
335
- * @static
336
- * @param {KoattyApplication} app
337
- * @param {*} target
338
- * @memberof Loader
339
- */
340
- static LoadAppEventHooks(app, target) {
341
- const eventFuncs = new Map();
342
- for (const event of koatty_core.AppEventArr) {
343
- let funcs;
344
- switch (event) {
345
- case "appBoot" /* AppEvent.appBoot */:
346
- funcs = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, "appBoot" /* AppEvent.appBoot */, target);
347
- if (koatty_lib.Helper.isArray(funcs)) {
348
- eventFuncs.set("appBoot" /* AppEvent.appBoot */, funcs);
349
- }
350
- break;
351
- case "appReady" /* AppEvent.appReady */:
352
- funcs = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, "appReady" /* AppEvent.appReady */, target);
353
- if (koatty_lib.Helper.isArray(funcs)) {
354
- eventFuncs.set("appReady" /* AppEvent.appReady */, funcs);
355
- }
356
- break;
357
- case "appStart" /* AppEvent.appStart */:
358
- funcs = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, "appStart" /* AppEvent.appStart */, target);
359
- if (koatty_lib.Helper.isArray(funcs)) {
360
- eventFuncs.set("appStart" /* AppEvent.appStart */, funcs);
361
- }
362
- break;
363
- case "appStop" /* AppEvent.appStop */:
364
- funcs = koatty_container.IOC.getClassMetadata(koatty_container.TAGGED_CLS, "appStop" /* AppEvent.appStop */, target);
365
- if (koatty_lib.Helper.isArray(funcs)) {
366
- eventFuncs.set("appStop" /* AppEvent.appStop */, funcs);
367
- }
368
- break;
369
- }
370
- }
371
- // loop event emit
372
- for (const [event, funcs] of eventFuncs) {
373
- for (const func of funcs) {
374
- app.once(event, () => func(app));
375
- }
376
- }
160
+ process.env.ROOT_PATH = t;
161
+ process.env.APP_PATH = o;
162
+ process.env.KOATTY_PATH = r;
163
+ a.Helper.define(e, "thinkPath", r);
164
+ process.env.THINK_PATH = r;
165
+ }
166
+ static GetComponentMeta(e, o) {
167
+ let r = [];
168
+ const n = t.IOC.getClassMetadata(t.TAGGED_CLS, E, o);
169
+ if (n) if (a.Helper.isArray(n)) r = n; else r.push(n);
170
+ if (r.length < 1) r = [ e.appPath ];
171
+ return r;
172
+ }
173
+ static GetConfigurationMeta(e, o) {
174
+ const r = t.IOC.getClassMetadata(t.TAGGED_CLS, O, o);
175
+ let n = [];
176
+ if (r) if (a.Helper.isArray(r)) n = r; else n.push(r);
177
+ return n;
178
+ }
179
+ static CheckAllComponents(e, t) {
180
+ const o = Loader.GetComponentMeta(e, t);
181
+ const r = Loader.GetConfigurationMeta(e, t);
182
+ const a = new Set;
183
+ i.Load(o, "", ((e, t, o) => {
184
+ m(e, t, o, a);
185
+ }), [ "**/**.js", "**/**.ts", "!**/**.d.ts" ], [ ...r, `${t.name || ".no"}.ts` ]);
186
+ a.clear();
187
+ }
188
+ static SetLogger(e) {
189
+ const t = e.getMetaData("_configs") || [];
190
+ const o = t[0] || {};
191
+ if (o.config) {
192
+ const t = o.config;
193
+ let r = "debug", a = "", n = [];
194
+ if (e.env === "production") r = "info";
195
+ if (t.logsLevel) r = t.logsLevel.toLowerCase();
196
+ if (t.logsPath) a = t.logsPath;
197
+ if (t.sensFields) n = t.sensFields;
198
+ h(e, {
199
+ logLevel: r,
200
+ logFilePath: a,
201
+ sensFields: n
202
+ });
377
203
  }
378
- /**
379
- * @description: Load all components
380
- * @param {KoattyApplication} app
381
- * @param {any} target
382
- * @return {*}
383
- */
384
- static async LoadAllComponents(app, target) {
385
- var _a;
386
- // Load configuration
387
- Logger.Log('Koatty', '', 'Load Configurations ...');
388
- // configuration metadata
389
- const configurationMeta = Loader.GetConfigurationMeta(app, target);
390
- const loader = new Loader(app);
391
- loader.LoadConfigs(configurationMeta);
392
- // Create Server
393
- const serveOpts = {
394
- hostname: app.config('app_host'),
395
- port: app.config('app_port'),
396
- protocol: app.config('protocol'),
397
- };
398
- koatty_lib.Helper.define(app, "server", koatty_serve.NewServe(app, serveOpts));
399
- // Create router
400
- const routerOpts = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
401
- koatty_lib.Helper.define(app, "router", koatty_router.NewRouter(app, routerOpts));
402
- // Load Components
403
- Logger.Log('Koatty', '', 'Load Components ...');
404
- await loader.LoadComponents();
405
- // Load Middleware
406
- Logger.Log('Koatty', '', 'Load Middlewares ...');
407
- await loader.LoadMiddlewares();
408
- // Load Services
409
- Logger.Log('Koatty', '', 'Load Services ...');
410
- await loader.LoadServices();
411
- // Load Controllers
412
- Logger.Log('Koatty', '', 'Load Controllers ...');
413
- const controllers = await loader.LoadControllers();
414
- // Load Routers
415
- Logger.Log('Koatty', '', 'Load Routers ...');
416
- loader.LoadRouter(controllers);
204
+ }
205
+ static LoadAppEventHooks(e, r) {
206
+ const n = new Map;
207
+ for (const e of o.AppEventArr) {
208
+ let o;
209
+ switch (e) {
210
+ case "appBoot":
211
+ o = t.IOC.getClassMetadata(t.TAGGED_CLS, "appBoot", r);
212
+ if (a.Helper.isArray(o)) n.set("appBoot", o);
213
+ break;
214
+
215
+ case "appReady":
216
+ o = t.IOC.getClassMetadata(t.TAGGED_CLS, "appReady", r);
217
+ if (a.Helper.isArray(o)) n.set("appReady", o);
218
+ break;
219
+
220
+ case "appStart":
221
+ o = t.IOC.getClassMetadata(t.TAGGED_CLS, "appStart", r);
222
+ if (a.Helper.isArray(o)) n.set("appStart", o);
223
+ break;
224
+
225
+ case "appStop":
226
+ o = t.IOC.getClassMetadata(t.TAGGED_CLS, "appStop", r);
227
+ if (a.Helper.isArray(o)) n.set("appStop", o);
228
+ break;
229
+ }
417
230
  }
418
- /**
419
- * Load configuration
420
- *
421
- * @param {string[]} [loadPath]
422
- * @memberof Loader
423
- */
424
- LoadConfigs(loadPath) {
425
- const frameConfig = {};
426
- // Logger.Debug(`Load configuration path: ${app.thinkPath}/config`);
427
- koatty_loader.Load(["./config"], this.app.koattyPath, function (name, path, exp) {
428
- frameConfig[name] = exp;
231
+ for (const [t, o] of n) for (const r of o) e.once(t, (() => r(e)));
232
+ }
233
+ static async LoadAllComponents(e, t) {
234
+ var o, r, s;
235
+ g.Log("Koatty", "", "Load Configurations ...");
236
+ const i = Loader.GetConfigurationMeta(e, t);
237
+ const c = new Loader(e);
238
+ c.LoadConfigs(i);
239
+ const p = (o = e.config("server")) !== null && o !== void 0 ? o : {
240
+ protocol: "http"
241
+ };
242
+ const f = (r = p.protocol) !== null && r !== void 0 ? r : "http";
243
+ a.Helper.define(e, "server", l.NewServe(e, p));
244
+ const d = (s = e.config(void 0, "router")) !== null && s !== void 0 ? s : {};
245
+ a.Helper.define(e, "router", n.NewRouter(e, {
246
+ protocol: f,
247
+ ...d
248
+ }));
249
+ g.Log("Koatty", "", "Load Components ...");
250
+ await c.LoadComponents();
251
+ g.Log("Koatty", "", "Load Middlewares ...");
252
+ await c.LoadMiddlewares();
253
+ g.Log("Koatty", "", "Load Services ...");
254
+ await c.LoadServices();
255
+ g.Log("Koatty", "", "Load Controllers ...");
256
+ const u = await c.LoadControllers();
257
+ g.Log("Koatty", "", "Load Routers ...");
258
+ c.LoadRouter(u);
259
+ }
260
+ LoadConfigs(t) {
261
+ const o = {};
262
+ i.Load([ "./config" ], this.app.koattyPath, (function(e, t, r) {
263
+ o[e] = r;
264
+ }));
265
+ if (a.Helper.isArray(t)) t = t.length > 0 ? t : [ "./config" ];
266
+ let r = e.LoadConfigs(t, this.app.appPath);
267
+ r = a.Helper.extend(o, r, !0);
268
+ this.app.setMetaData("_configs", r);
269
+ }
270
+ async LoadMiddlewares() {
271
+ var e;
272
+ let r = this.app.config(void 0, "middleware");
273
+ if (a.Helper.isEmpty(r)) r = {
274
+ config: {},
275
+ list: [],
276
+ routeList: []
277
+ };
278
+ const n = (e = t.IOC.listClass("MIDDLEWARE")) !== null && e !== void 0 ? e : [];
279
+ n.forEach((e => {
280
+ var r;
281
+ e.id = ((r = e.id) !== null && r !== void 0 ? r : "").replace("MIDDLEWARE:", "");
282
+ if (e.id && a.Helper.isClass(e.target)) {
283
+ t.IOC.reg(e.id, e.target, {
284
+ scope: "Prototype",
285
+ type: "MIDDLEWARE",
286
+ args: []
429
287
  });
430
- if (koatty_lib.Helper.isArray(loadPath)) {
431
- loadPath = loadPath.length > 0 ? loadPath : ["./config"];
432
- }
433
- let appConfig = koatty_config.LoadConfigs(loadPath, this.app.appPath);
434
- appConfig = koatty_lib.Helper.extend(frameConfig, appConfig, true);
435
- this.app.setMetaData("_configs", appConfig);
288
+ const r = t.IOC.getInsByClass(e.target);
289
+ if (!o.implementsMiddlewareInterface(r)) throw Error(`The middleware ${e.id} must implements interface 'IMiddleware'.`);
290
+ }
291
+ }));
292
+ const s = r.list || [];
293
+ const i = new Set([]);
294
+ s.forEach((e => {
295
+ i.add(e);
296
+ }));
297
+ const l = r.routeList || [];
298
+ const c = new Set([]);
299
+ l.forEach((e => {
300
+ c.add(e);
301
+ }));
302
+ const p = r.config || {};
303
+ for (const e of i) {
304
+ const o = t.IOC.get(e, "MIDDLEWARE");
305
+ if (!o) throw Error(`Middleware ${e} load error.`);
306
+ if (!a.Helper.isFunction(o.run)) throw Error(`The middleware ${e} must implements interface 'IMiddleware'.`);
307
+ g.Debug(`Load middleware: ${e}`);
308
+ const r = p[e] || {};
309
+ const n = await o.run(r, this.app);
310
+ if (a.Helper.isFunction(n)) if (n.length < 3) this.app.use(n); else this.app.useExp(n);
436
311
  }
437
- /**
438
- * Load middlewares
439
- * [async]
440
- * @memberof Loader
441
- */
442
- async LoadMiddlewares() {
443
- var _a;
444
- let middlewareConf = this.app.config(undefined, "middleware");
445
- if (koatty_lib.Helper.isEmpty(middlewareConf)) {
446
- middlewareConf = { config: {}, list: [] };
447
- }
448
- //Mount default middleware
449
- // Load(loadPath || ["./middleware"], app.koattyPath);
450
- //Mount application middleware
451
- // const middleware: any = {};
452
- const appMiddleware = (_a = koatty_container.IOC.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
453
- appMiddleware.forEach((item) => {
454
- var _a;
455
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
456
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
457
- koatty_container.IOC.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
458
- const ctl = koatty_container.IOC.getInsByClass(item.target);
459
- if (!koatty_core.implementsMiddlewareInterface(ctl)) {
460
- throw Error(`The middleware ${item.id} must implements interface 'IMiddleware'.`);
461
- }
462
- }
463
- });
464
- const middlewareConfList = middlewareConf.list || [];
465
- //de-duplication
466
- const appMList = new Set([]);
467
- middlewareConfList.forEach((item) => {
468
- appMList.add(item);
469
- });
470
- //Automatically call middleware
471
- const middlewareConfig = middlewareConf.config || {};
472
- for (const key of appMList) {
473
- const handle = koatty_container.IOC.get(key, "MIDDLEWARE");
474
- if (!handle) {
475
- throw Error(`Middleware ${key} load error.`);
476
- }
477
- if (!koatty_lib.Helper.isFunction(handle.run)) {
478
- throw Error(`The middleware ${key} must implements interface 'IMiddleware'.`);
479
- }
480
- if (middlewareConfig[key] === false) {
481
- Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
482
- continue;
483
- }
484
- Logger.Debug(`Load middleware: ${key}`);
485
- const result = await handle.run(middlewareConfig[key] || {}, this.app);
486
- if (koatty_lib.Helper.isFunction(result)) {
487
- if (result.length < 3) {
488
- this.app.use(result);
489
- }
490
- else {
491
- this.app.useExp(result);
492
- }
493
- }
494
- }
312
+ for (const e of c) {
313
+ const r = t.IOC.get(e, "MIDDLEWARE");
314
+ if (!r) throw Error(`Router middleware ${e} load error.`);
315
+ if (!a.Helper.isFunction(r.run)) throw Error(`The router middleware ${e} must implements interface 'IMiddleware'.`);
316
+ g.Debug(`Load router middleware: ${e}`);
317
+ const n = await r.run(p[e] || {}, this.app);
318
+ if (a.Helper.isFunction(n)) this.app.setMetaData(`routerMiddleware_${e}`, n.length > 2 ? o.parseExp(n) : n);
495
319
  }
496
- /**
497
- * Load controllers
498
- *
499
- * @memberof Loader
500
- */
501
- async LoadControllers() {
502
- const controllerList = koatty_container.IOC.listClass("CONTROLLER");
503
- const controllers = [];
504
- controllerList.forEach((item) => {
505
- var _a;
506
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
507
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
508
- Logger.Debug(`Load controller: ${item.id}`);
509
- // registering to IOC
510
- koatty_container.IOC.reg(item.id, item.target, { scope: "Prototype", type: "CONTROLLER", args: [] });
511
- const ctl = koatty_container.IOC.getInsByClass(item.target);
512
- if (!koatty_core.implementsControllerInterface(ctl)) {
513
- throw Error(`The controller ${item.id} must implements interface 'IController'.`);
514
- }
515
- controllers.push(item.id);
516
- }
320
+ }
321
+ async LoadControllers() {
322
+ const e = t.IOC.listClass("CONTROLLER");
323
+ const r = [];
324
+ e.forEach((e => {
325
+ var n;
326
+ e.id = ((n = e.id) !== null && n !== void 0 ? n : "").replace("CONTROLLER:", "");
327
+ if (e.id && a.Helper.isClass(e.target)) {
328
+ g.Debug(`Load controller: ${e.id}`);
329
+ t.IOC.reg(e.id, e.target, {
330
+ scope: "Prototype",
331
+ type: "CONTROLLER",
332
+ args: []
517
333
  });
518
- return controllers;
519
- }
520
- /**
521
- * Load services
522
- *
523
- * @memberof Loader
524
- */
525
- async LoadServices() {
526
- const serviceList = koatty_container.IOC.listClass("SERVICE");
527
- serviceList.forEach((item) => {
528
- var _a;
529
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
530
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
531
- Logger.Debug(`Load service: ${item.id}`);
532
- // registering to IOC
533
- koatty_container.IOC.reg(item.id, item.target, { scope: "Singleton", type: "SERVICE", args: [] });
534
- const ctl = koatty_container.IOC.getInsByClass(item.target);
535
- if (!koatty_core.implementsServiceInterface(ctl)) {
536
- throw Error(`The service ${item.id} must implements interface 'IService'.`);
537
- }
538
- }
334
+ const a = t.IOC.getInsByClass(e.target);
335
+ if (!o.implementsControllerInterface(a)) throw Error(`The controller ${e.id} must implements interface 'IController'.`);
336
+ r.push(e.id);
337
+ }
338
+ }));
339
+ return r;
340
+ }
341
+ async LoadServices() {
342
+ const e = t.IOC.listClass("SERVICE");
343
+ e.forEach((e => {
344
+ var r;
345
+ e.id = ((r = e.id) !== null && r !== void 0 ? r : "").replace("SERVICE:", "");
346
+ if (e.id && a.Helper.isClass(e.target)) {
347
+ g.Debug(`Load service: ${e.id}`);
348
+ t.IOC.reg(e.id, e.target, {
349
+ scope: "Singleton",
350
+ type: "SERVICE",
351
+ args: []
539
352
  });
540
- }
541
- /**
542
- * Load components
543
- *
544
- * @memberof Loader
545
- */
546
- async LoadComponents() {
547
- var _a, _b;
548
- const componentList = koatty_container.IOC.listClass("COMPONENT");
549
- const pluginList = [];
550
- componentList.forEach(async (item) => {
551
- var _a;
552
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
553
- if (koatty_lib.Helper.isClass(item.target)) {
554
- // registering to IOC
555
- koatty_container.IOC.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
556
- if (item.id && (item.id).endsWith("Plugin")) {
557
- const ctl = koatty_container.IOC.getInsByClass(item.target);
558
- if (!koatty_core.implementsPluginInterface(ctl)) {
559
- throw Error(`The plugin ${item.id} must implements interface 'IPlugin'.`);
560
- }
561
- pluginList.push(item.id);
562
- }
563
- if (item.id && (item.id).endsWith("Aspect")) {
564
- const ctl = koatty_container.IOC.getInsByClass(item.target);
565
- if (!koatty_core.implementsAspectInterface(ctl)) {
566
- throw Error(`The aspect ${item.id} must implements interface 'IAspect'.`);
567
- }
568
- }
569
- }
353
+ const r = t.IOC.getInsByClass(e.target);
354
+ if (!o.implementsServiceInterface(r)) throw Error(`The service ${e.id} must implements interface 'IService'.`);
355
+ }
356
+ }));
357
+ }
358
+ async LoadComponents() {
359
+ var e, r;
360
+ const n = t.IOC.listClass("COMPONENT");
361
+ const s = [];
362
+ n.forEach((async e => {
363
+ var r;
364
+ e.id = ((r = e.id) !== null && r !== void 0 ? r : "").replace("COMPONENT:", "");
365
+ if (a.Helper.isClass(e.target)) {
366
+ t.IOC.reg(e.id, e.target, {
367
+ scope: "Singleton",
368
+ type: "COMPONENT",
369
+ args: []
570
370
  });
571
- // load plugin config
572
- let pluginsConf = this.app.config(undefined, "plugin");
573
- if (koatty_lib.Helper.isEmpty(pluginsConf)) {
574
- pluginsConf = { config: {}, list: [] };
371
+ if (e.id && e.id.endsWith("Plugin")) {
372
+ const r = t.IOC.getInsByClass(e.target);
373
+ if (!o.implementsPluginInterface(r)) throw Error(`The plugin ${e.id} must implements interface 'IPlugin'.`);
374
+ s.push(e.id);
575
375
  }
576
- const pluginConfList = (_a = pluginsConf.list) !== null && _a !== void 0 ? _a : [];
577
- // load plugin list
578
- for (const key of pluginConfList) {
579
- const handle = koatty_container.IOC.get(key, "COMPONENT");
580
- if (!handle) {
581
- throw Error(`Plugin ${key} load error.`);
582
- }
583
- if (!koatty_lib.Helper.isFunction(handle.run)) {
584
- throw Error(`Plugin ${key} must implements interface 'IPlugin'.`);
585
- }
586
- if (pluginsConf.config[key] === false) {
587
- Logger.Warn(`Plugin ${key} already loaded but not effective.`);
588
- continue;
589
- }
590
- // sync exec
591
- await handle.run((_b = pluginsConf.config[key]) !== null && _b !== void 0 ? _b : {}, this.app);
376
+ if (e.id && e.id.endsWith("Aspect")) {
377
+ const r = t.IOC.getInsByClass(e.target);
378
+ if (!o.implementsAspectInterface(r)) throw Error(`The aspect ${e.id} must implements interface 'IAspect'.`);
592
379
  }
380
+ }
381
+ }));
382
+ let i = this.app.config(void 0, "plugin");
383
+ if (a.Helper.isEmpty(i)) i = {
384
+ config: {},
385
+ list: []
386
+ };
387
+ const l = (e = i.list) !== null && e !== void 0 ? e : [];
388
+ for (const e of l) {
389
+ const o = t.IOC.get(e, "COMPONENT");
390
+ if (!o) throw Error(`Plugin ${e} load error.`);
391
+ if (!a.Helper.isFunction(o.run)) throw Error(`Plugin ${e} must implements interface 'IPlugin'.`);
392
+ if (i.config[e] === !1) {
393
+ g.Warn(`Plugin ${e} already loaded but not effective.`);
394
+ continue;
395
+ }
396
+ await o.run((r = i.config[e]) !== null && r !== void 0 ? r : {}, this.app);
593
397
  }
594
- /**
595
- * @description: load router
596
- * @param {string} ctls
597
- * @return {*}
598
- */
599
- async LoadRouter(ctls) {
600
- // load router
601
- await this.app.router.LoadRouter(this.app, ctls);
602
- }
398
+ }
399
+ async LoadRouter(e) {
400
+ await this.app.router.LoadRouter(this.app, e);
401
+ }
603
402
  }
604
403
 
605
404
  /*
@@ -610,229 +409,147 @@ class Loader {
610
409
  * @LastEditTime: 2025-01-14 16:11:21
611
410
  * @License: BSD (3-Clause)
612
411
  * @Copyright (c): <richenlin(at)gmail.com>
613
- */
614
- /**
615
- * Bootstrap application decorator
616
- *
617
- * @export
618
- * @param {Function} [bootFunc]
619
- * @returns {ClassDecorator}
620
- */
621
- function Bootstrap(bootFunc) {
622
- return function (target) {
623
- if (!(target.prototype instanceof koatty_core.Koatty)) {
624
- throw new Error(`class does not inherit from Koatty`);
625
- }
626
- executeBootstrap(target, bootFunc);
627
- };
412
+ */ function I(e) {
413
+ return function(t) {
414
+ if (!(t.prototype instanceof o.Koatty)) throw new Error(`class does not inherit from Koatty`);
415
+ S(t, e);
416
+ };
628
417
  }
629
- /**
630
- * Actively perform dependency injection
631
- * Parse the decorator, return the instantiated app.
632
- * @export ExecBootStrap
633
- * @param {Function} [bootFunc] callback function
634
- * @returns
635
- */
636
- function ExecBootStrap(bootFunc) {
637
- return async (target) => {
638
- if (!(target.prototype instanceof koatty_core.Koatty)) {
639
- throw new Error(`class ${target.name} does not inherit from Koatty`);
640
- }
641
- return await executeBootstrap(target, bootFunc, true);
642
- };
418
+
419
+ function P(e) {
420
+ return async t => {
421
+ if (!(t.prototype instanceof o.Koatty)) throw new Error(`class ${t.name} does not inherit from Koatty`);
422
+ return await S(t, e, !0);
423
+ };
643
424
  }
644
- /**
645
- * Define project scan path
646
- *
647
- * @export
648
- * @param {(string | string[])} [scanPath]
649
- * @returns {ClassDecorator}
650
- */
651
- function ComponentScan(scanPath) {
652
- return (target) => {
653
- if (!(target.prototype instanceof koatty_core.Koatty)) {
654
- throw new Error(`class does not inherit from Koatty`);
655
- }
656
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
657
- koatty_container.IOC.saveClassMetadata(koatty_container.TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
658
- };
425
+
426
+ function b(e) {
427
+ return r => {
428
+ if (!(r.prototype instanceof o.Koatty)) throw new Error(`class does not inherit from Koatty`);
429
+ e = e !== null && e !== void 0 ? e : "";
430
+ t.IOC.saveClassMetadata(t.TAGGED_CLS, E, e, r);
431
+ };
659
432
  }
660
- /**
661
- * Define project configuration scan path
662
- *
663
- * @export
664
- * @param {(string | string[])} [scanPath]
665
- * @returns {ClassDecorator}
666
- */
667
- function ConfigurationScan(scanPath) {
668
- return (target) => {
669
- if (!(target.prototype instanceof koatty_core.Koatty)) {
670
- throw new Error(`class does not inherit from Koatty`);
671
- }
672
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
673
- koatty_container.IOC.saveClassMetadata(koatty_container.TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
674
- };
433
+
434
+ function A(e) {
435
+ return r => {
436
+ if (!(r.prototype instanceof o.Koatty)) throw new Error(`class does not inherit from Koatty`);
437
+ e = e !== null && e !== void 0 ? e : "";
438
+ t.IOC.saveClassMetadata(t.TAGGED_CLS, O, e, r);
439
+ };
675
440
  }
676
- /**
677
- * @description: bind App event hook func
678
- * example:
679
- * export function TestDecorator(): ClassDecorator {
680
- * return (target: Function) => {
681
- * BindEventHook(AppEvent.appBoot, (app: KoattyApplication) => {
682
- * // todo
683
- * return Promise.resolve();
684
- * }, target)
685
- * }
686
- * }
687
- * @param {AppEvent} eventName
688
- * @param {EventHookFunc} eventFunc
689
- * @param {any} target
690
- * @return {*}
691
- */
692
- function BindEventHook(eventName, eventFunc, target) {
693
- koatty_container.IOC.attachClassMetadata(koatty_container.TAGGED_CLS, eventName, eventFunc, target);
441
+
442
+ function H(e, o, r) {
443
+ t.IOC.attachClassMetadata(t.TAGGED_CLS, e, o, r);
694
444
  }
695
- /**
696
- * execute bootstrap
697
- *
698
- * @param {*} target
699
- * @param {Function} bootFunc
700
- * @param {boolean} [isInitiative=false] Whether to actively execute app instantiation,
701
- * mainly for unittest scenarios, you need to actively obtain app instances
702
- * @returns {Promise<void>}
703
- */
704
- const executeBootstrap = async function (target, bootFunc, isInitiative = false) {
705
- // checked runtime
706
- checkRuntime();
707
- // unittest running environment
708
- const isUTRuntime = checkUTRuntime();
709
- if (!isInitiative && isUTRuntime) {
710
- return;
711
- }
712
- const app = Reflect.construct(target, []);
713
- // unittest does not print startup logs
714
- if (isUTRuntime) {
715
- app.silent = true;
716
- Logger.enable(false);
717
- }
718
- try {
719
- if (!app.silent)
720
- Logger.Log("Koatty", LOGO);
721
- if (!(app instanceof koatty_core.Koatty)) {
722
- throw new Error(`class ${target.name} does not inherit from Koatty`);
723
- }
724
- // Initialize env
725
- Loader.initialize(app);
726
- // exec bootFunc
727
- if (koatty_lib.Helper.isFunction(bootFunc)) {
728
- Logger.Log('Koatty', '', 'Execute bootFunc ...');
729
- await bootFunc(app);
730
- }
731
- // Set IOC.app
732
- koatty_container.IOC.setApp(app);
733
- // Check all bean
734
- Logger.Log('Koatty', '', 'ComponentScan ...');
735
- Loader.CheckAllComponents(app, target);
736
- // Load App event hooks
737
- Loader.LoadAppEventHooks(app, target);
738
- Logger.Log('Koatty', '', 'Emit App Boot ...');
739
- await asyncEvent(app, "appBoot" /* AppEvent.appBoot */);
740
- // Load All components
741
- await Loader.LoadAllComponents(app, target);
742
- // Emit app ready event
743
- Logger.Log('Koatty', '', 'Emit App Ready ...');
744
- await asyncEvent(app, "appReady" /* AppEvent.appReady */);
745
- if (!isUTRuntime) {
746
- // Start Server
747
- app.listen(listenCallback);
748
- }
749
- return app;
750
- }
751
- catch (err) {
752
- Logger.Error(err);
753
- process.exit();
754
- }
755
- };
756
- /**
757
- * Listening callback function
758
- *
759
- * @param {Koatty} app
760
- * @returns {*}
761
- */
762
- const listenCallback = (app) => {
763
- let servers = [];
764
- if (!Array.isArray(app.server)) {
765
- servers = [app.server];
766
- }
767
- else {
768
- servers = app.server;
445
+
446
+ const S = async function(e, r, n = !1) {
447
+ L();
448
+ const s = v();
449
+ if (!n && s) return;
450
+ const i = Reflect.construct(e, []);
451
+ if (s) {
452
+ i.silent = !0;
453
+ g.enable(!1);
454
+ }
455
+ try {
456
+ if (!i.silent) g.Log("Koatty", w);
457
+ if (!(i instanceof o.Koatty)) throw new Error(`class ${e.name} does not inherit from Koatty`);
458
+ Loader.initialize(i);
459
+ if (a.Helper.isFunction(r)) {
460
+ g.Log("Koatty", "", "Execute bootFunc ...");
461
+ await r(i);
769
462
  }
770
- Logger.Log('Koatty', '', '====================================');
771
- Logger.Log("Koatty", "", `Nodejs Version: ${process.version}`);
772
- Logger.Log("Koatty", "", `Koatty Version: v${KOATTY_VERSION}`);
773
- Logger.Log("Koatty", "", `App Environment: ${app.env}`);
774
- servers.forEach(s => {
775
- Logger.Log('Koatty', '', `Server: ${(s.options.protocol).toUpperCase()} running at ${s.options.protocol === "http2" ?
776
- "https" : s.options.protocol}://${s.options.hostname || '127.0.0.1'}:${s.options.port}/`);
777
- });
778
- Logger.Log("Koatty", "", "====================================");
779
- if (app.appDebug)
780
- Logger.Warn(`Running in debug mode.`);
781
- // Set Logger
782
- Loader.SetLogger(app);
463
+ t.IOC.setApp(i);
464
+ g.Log("Koatty", "", "ComponentScan ...");
465
+ Loader.CheckAllComponents(i, e);
466
+ Loader.LoadAppEventHooks(i, e);
467
+ g.Log("Koatty", "", "Emit App Boot ...");
468
+ await o.asyncEvent(i, "appBoot");
469
+ await Loader.LoadAllComponents(i, e);
470
+ g.Log("Koatty", "", "Emit App Ready ...");
471
+ await o.asyncEvent(i, "appReady");
472
+ if (!s) i.listen(M);
473
+ return i;
474
+ } catch (e) {
475
+ g.Error(e);
476
+ process.exit();
477
+ }
783
478
  };
784
- /**
785
- * Execute event as async
786
- *
787
- * @param {Koatty} event
788
- * @param {string} eventName
789
- */
790
- const asyncEvent = async function (event, eventName) {
791
- const ls = event.listeners(eventName);
792
- // eslint-disable-next-line no-restricted-syntax
793
- for await (const func of ls) {
794
- if (koatty_lib.Helper.isFunction(func)) {
795
- func();
796
- }
797
- }
798
- return event.removeAllListeners(eventName);
479
+
480
+ const M = e => {
481
+ let t = [];
482
+ if (!Array.isArray(e.server)) t = [ e.server ]; else t = e.server;
483
+ g.Log("Koatty", "", "====================================");
484
+ g.Log("Koatty", "", `Nodejs Version: ${process.version}`);
485
+ g.Log("Koatty", "", `Koatty Version: v${y}`);
486
+ g.Log("Koatty", "", `App Environment: ${e.env}`);
487
+ t.forEach((e => {
488
+ g.Log("Koatty", "", `Server: ${e.options.protocol.toUpperCase()} running at ${e.options.protocol === "http2" ? "https" : e.options.protocol}://${e.options.hostname || "127.0.0.1"}:${e.options.port}/`);
489
+ }));
490
+ g.Log("Koatty", "", "====================================");
491
+ if (e.appDebug) g.Warn(`Running in debug mode.`);
492
+ Loader.SetLogger(e);
799
493
  };
800
494
 
801
495
  Object.defineProperty(exports, "Config", {
802
- enumerable: true,
803
- get: function () { return koatty_config.Config; }
496
+ enumerable: !0,
497
+ get: function() {
498
+ return e.Config;
499
+ }
804
500
  });
501
+
805
502
  Object.defineProperty(exports, "Helper", {
806
- enumerable: true,
807
- get: function () { return koatty_lib.Helper; }
503
+ enumerable: !0,
504
+ get: function() {
505
+ return a.Helper;
506
+ }
808
507
  });
809
- exports.BindEventHook = BindEventHook;
810
- exports.Bootstrap = Bootstrap;
811
- exports.ComponentScan = ComponentScan;
812
- exports.ConfigurationScan = ConfigurationScan;
813
- exports.ExecBootStrap = ExecBootStrap;
814
- exports.Logger = Logger;
815
- Object.keys(koatty_container).forEach(function (k) {
816
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
817
- enumerable: true,
818
- get: function () { return koatty_container[k]; }
508
+
509
+ exports.BindEventHook = H;
510
+
511
+ exports.Bootstrap = I;
512
+
513
+ exports.ComponentScan = b;
514
+
515
+ exports.ConfigurationScan = A;
516
+
517
+ exports.ExecBootStrap = P;
518
+
519
+ exports.Logger = g;
520
+
521
+ Object.keys(t).forEach((function(e) {
522
+ if (e !== "default" && !Object.prototype.hasOwnProperty.call(exports, e)) Object.defineProperty(exports, e, {
523
+ enumerable: !0,
524
+ get: function() {
525
+ return t[e];
526
+ }
819
527
  });
820
- });
821
- Object.keys(koatty_core).forEach(function (k) {
822
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
823
- enumerable: true,
824
- get: function () { return koatty_core[k]; }
528
+ }));
529
+
530
+ Object.keys(o).forEach((function(e) {
531
+ if (e !== "default" && !Object.prototype.hasOwnProperty.call(exports, e)) Object.defineProperty(exports, e, {
532
+ enumerable: !0,
533
+ get: function() {
534
+ return o[e];
535
+ }
825
536
  });
826
- });
827
- Object.keys(koatty_exception).forEach(function (k) {
828
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
829
- enumerable: true,
830
- get: function () { return koatty_exception[k]; }
537
+ }));
538
+
539
+ Object.keys(r).forEach((function(e) {
540
+ if (e !== "default" && !Object.prototype.hasOwnProperty.call(exports, e)) Object.defineProperty(exports, e, {
541
+ enumerable: !0,
542
+ get: function() {
543
+ return r[e];
544
+ }
831
545
  });
832
- });
833
- Object.keys(koatty_router).forEach(function (k) {
834
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
835
- enumerable: true,
836
- get: function () { return koatty_router[k]; }
546
+ }));
547
+
548
+ Object.keys(n).forEach((function(e) {
549
+ if (e !== "default" && !Object.prototype.hasOwnProperty.call(exports, e)) Object.defineProperty(exports, e, {
550
+ enumerable: !0,
551
+ get: function() {
552
+ return n[e];
553
+ }
837
554
  });
838
- });
555
+ }));