koatty 3.12.0 → 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-03-15 23:04:17
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.12.0";
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,19 +123,11 @@ 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:
@@ -185,423 +136,269 @@ https://github.com/koatty
185
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 protocol = app.config('protocol');
394
- const serveOpts = {
395
- hostname: app.config('app_host'),
396
- port: app.config('app_port'),
397
- protocol: protocol,
398
- };
399
- koatty_lib.Helper.define(app, "server", koatty_serve.NewServe(app, serveOpts));
400
- // Create router
401
- const routerOpts = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
402
- koatty_lib.Helper.define(app, "router", koatty_router.NewRouter(app, { protocol, ...routerOpts }));
403
- // Load Components
404
- Logger.Log('Koatty', '', 'Load Components ...');
405
- await loader.LoadComponents();
406
- // Load Middleware
407
- Logger.Log('Koatty', '', 'Load Middlewares ...');
408
- await loader.LoadMiddlewares();
409
- // Load Services
410
- Logger.Log('Koatty', '', 'Load Services ...');
411
- await loader.LoadServices();
412
- // Load Controllers
413
- Logger.Log('Koatty', '', 'Load Controllers ...');
414
- const controllers = await loader.LoadControllers();
415
- // Load Routers
416
- Logger.Log('Koatty', '', 'Load Routers ...');
417
- 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
+ }
418
230
  }
419
- /**
420
- * Load configuration
421
- *
422
- * @param {string[]} [loadPath]
423
- * @memberof Loader
424
- */
425
- LoadConfigs(loadPath) {
426
- const frameConfig = {};
427
- // Logger.Debug(`Load configuration path: ${app.thinkPath}/config`);
428
- koatty_loader.Load(["./config"], this.app.koattyPath, function (name, path, exp) {
429
- 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: []
430
287
  });
431
- if (koatty_lib.Helper.isArray(loadPath)) {
432
- loadPath = loadPath.length > 0 ? loadPath : ["./config"];
433
- }
434
- let appConfig = koatty_config.LoadConfigs(loadPath, this.app.appPath);
435
- appConfig = koatty_lib.Helper.extend(frameConfig, appConfig, true);
436
- 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);
437
311
  }
438
- /**
439
- * Load middlewares
440
- * [async]
441
- * @memberof Loader
442
- */
443
- async LoadMiddlewares() {
444
- var _a;
445
- let middlewareConf = this.app.config(undefined, "middleware");
446
- if (koatty_lib.Helper.isEmpty(middlewareConf)) {
447
- middlewareConf = { config: {}, list: [] };
448
- }
449
- //Mount default middleware
450
- // Load(loadPath || ["./middleware"], app.koattyPath);
451
- //Mount application middleware
452
- // const middleware: any = {};
453
- const appMiddleware = (_a = koatty_container.IOC.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
454
- appMiddleware.forEach((item) => {
455
- var _a;
456
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
457
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
458
- koatty_container.IOC.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
459
- const ctl = koatty_container.IOC.getInsByClass(item.target);
460
- if (!koatty_core.implementsMiddlewareInterface(ctl)) {
461
- throw Error(`The middleware ${item.id} must implements interface 'IMiddleware'.`);
462
- }
463
- }
464
- });
465
- const middlewareConfList = middlewareConf.list || [];
466
- //de-duplication
467
- const appMList = new Set([]);
468
- middlewareConfList.forEach((item) => {
469
- appMList.add(item);
470
- });
471
- //Automatically call middleware
472
- const middlewareConfig = middlewareConf.config || {};
473
- for (const key of appMList) {
474
- const handle = koatty_container.IOC.get(key, "MIDDLEWARE");
475
- if (!handle) {
476
- throw Error(`Middleware ${key} load error.`);
477
- }
478
- if (!koatty_lib.Helper.isFunction(handle.run)) {
479
- throw Error(`The middleware ${key} must implements interface 'IMiddleware'.`);
480
- }
481
- // if (middlewareConfig[key] === false) {
482
- // Logger.Warn(`The middleware ${key} has been loaded but not executed.`);
483
- // continue;
484
- // }
485
- Logger.Debug(`Load middleware: ${key}`);
486
- const middlewareOpt = middlewareConfig[key] || {};
487
- const result = await handle.run(middlewareOpt, this.app);
488
- if (koatty_lib.Helper.isFunction(result)) {
489
- if (result.length < 3) {
490
- this.app.use(result);
491
- }
492
- else {
493
- this.app.useExp(result);
494
- }
495
- }
496
- }
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);
497
319
  }
498
- /**
499
- * Load controllers
500
- *
501
- * @memberof Loader
502
- */
503
- async LoadControllers() {
504
- const controllerList = koatty_container.IOC.listClass("CONTROLLER");
505
- const controllers = [];
506
- controllerList.forEach((item) => {
507
- var _a;
508
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
509
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
510
- Logger.Debug(`Load controller: ${item.id}`);
511
- // registering to IOC
512
- koatty_container.IOC.reg(item.id, item.target, { scope: "Prototype", type: "CONTROLLER", args: [] });
513
- const ctl = koatty_container.IOC.getInsByClass(item.target);
514
- if (!koatty_core.implementsControllerInterface(ctl)) {
515
- throw Error(`The controller ${item.id} must implements interface 'IController'.`);
516
- }
517
- controllers.push(item.id);
518
- }
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: []
519
333
  });
520
- return controllers;
521
- }
522
- /**
523
- * Load services
524
- *
525
- * @memberof Loader
526
- */
527
- async LoadServices() {
528
- const serviceList = koatty_container.IOC.listClass("SERVICE");
529
- serviceList.forEach((item) => {
530
- var _a;
531
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
532
- if (item.id && koatty_lib.Helper.isClass(item.target)) {
533
- Logger.Debug(`Load service: ${item.id}`);
534
- // registering to IOC
535
- koatty_container.IOC.reg(item.id, item.target, { scope: "Singleton", type: "SERVICE", args: [] });
536
- const ctl = koatty_container.IOC.getInsByClass(item.target);
537
- if (!koatty_core.implementsServiceInterface(ctl)) {
538
- throw Error(`The service ${item.id} must implements interface 'IService'.`);
539
- }
540
- }
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: []
541
352
  });
542
- }
543
- /**
544
- * Load components
545
- *
546
- * @memberof Loader
547
- */
548
- async LoadComponents() {
549
- var _a, _b;
550
- const componentList = koatty_container.IOC.listClass("COMPONENT");
551
- const pluginList = [];
552
- componentList.forEach(async (item) => {
553
- var _a;
554
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
555
- if (koatty_lib.Helper.isClass(item.target)) {
556
- // registering to IOC
557
- koatty_container.IOC.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
558
- if (item.id && (item.id).endsWith("Plugin")) {
559
- const ctl = koatty_container.IOC.getInsByClass(item.target);
560
- if (!koatty_core.implementsPluginInterface(ctl)) {
561
- throw Error(`The plugin ${item.id} must implements interface 'IPlugin'.`);
562
- }
563
- pluginList.push(item.id);
564
- }
565
- if (item.id && (item.id).endsWith("Aspect")) {
566
- const ctl = koatty_container.IOC.getInsByClass(item.target);
567
- if (!koatty_core.implementsAspectInterface(ctl)) {
568
- throw Error(`The aspect ${item.id} must implements interface 'IAspect'.`);
569
- }
570
- }
571
- }
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: []
572
370
  });
573
- // load plugin config
574
- let pluginsConf = this.app.config(undefined, "plugin");
575
- if (koatty_lib.Helper.isEmpty(pluginsConf)) {
576
- 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);
577
375
  }
578
- const pluginConfList = (_a = pluginsConf.list) !== null && _a !== void 0 ? _a : [];
579
- // load plugin list
580
- for (const key of pluginConfList) {
581
- const handle = koatty_container.IOC.get(key, "COMPONENT");
582
- if (!handle) {
583
- throw Error(`Plugin ${key} load error.`);
584
- }
585
- if (!koatty_lib.Helper.isFunction(handle.run)) {
586
- throw Error(`Plugin ${key} must implements interface 'IPlugin'.`);
587
- }
588
- if (pluginsConf.config[key] === false) {
589
- Logger.Warn(`Plugin ${key} already loaded but not effective.`);
590
- continue;
591
- }
592
- // sync exec
593
- 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'.`);
594
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);
595
397
  }
596
- /**
597
- * @description: load router
598
- * @param {string} ctls
599
- * @return {*}
600
- */
601
- async LoadRouter(ctls) {
602
- // load router
603
- await this.app.router.LoadRouter(this.app, ctls);
604
- }
398
+ }
399
+ async LoadRouter(e) {
400
+ await this.app.router.LoadRouter(this.app, e);
401
+ }
605
402
  }
606
403
 
607
404
  /*
@@ -612,229 +409,147 @@ class Loader {
612
409
  * @LastEditTime: 2025-01-14 16:11:21
613
410
  * @License: BSD (3-Clause)
614
411
  * @Copyright (c): <richenlin(at)gmail.com>
615
- */
616
- /**
617
- * Bootstrap application decorator
618
- *
619
- * @export
620
- * @param {Function} [bootFunc]
621
- * @returns {ClassDecorator}
622
- */
623
- function Bootstrap(bootFunc) {
624
- return function (target) {
625
- if (!(target.prototype instanceof koatty_core.Koatty)) {
626
- throw new Error(`class does not inherit from Koatty`);
627
- }
628
- executeBootstrap(target, bootFunc);
629
- };
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
+ };
630
417
  }
631
- /**
632
- * Actively perform dependency injection
633
- * Parse the decorator, return the instantiated app.
634
- * @export ExecBootStrap
635
- * @param {Function} [bootFunc] callback function
636
- * @returns
637
- */
638
- function ExecBootStrap(bootFunc) {
639
- return async (target) => {
640
- if (!(target.prototype instanceof koatty_core.Koatty)) {
641
- throw new Error(`class ${target.name} does not inherit from Koatty`);
642
- }
643
- return await executeBootstrap(target, bootFunc, true);
644
- };
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
+ };
645
424
  }
646
- /**
647
- * Define project scan path
648
- *
649
- * @export
650
- * @param {(string | string[])} [scanPath]
651
- * @returns {ClassDecorator}
652
- */
653
- function ComponentScan(scanPath) {
654
- return (target) => {
655
- if (!(target.prototype instanceof koatty_core.Koatty)) {
656
- throw new Error(`class does not inherit from Koatty`);
657
- }
658
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
659
- koatty_container.IOC.saveClassMetadata(koatty_container.TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
660
- };
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
+ };
661
432
  }
662
- /**
663
- * Define project configuration scan path
664
- *
665
- * @export
666
- * @param {(string | string[])} [scanPath]
667
- * @returns {ClassDecorator}
668
- */
669
- function ConfigurationScan(scanPath) {
670
- return (target) => {
671
- if (!(target.prototype instanceof koatty_core.Koatty)) {
672
- throw new Error(`class does not inherit from Koatty`);
673
- }
674
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
675
- koatty_container.IOC.saveClassMetadata(koatty_container.TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
676
- };
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
+ };
677
440
  }
678
- /**
679
- * @description: bind App event hook func
680
- * example:
681
- * export function TestDecorator(): ClassDecorator {
682
- * return (target: Function) => {
683
- * BindEventHook(AppEvent.appBoot, (app: KoattyApplication) => {
684
- * // todo
685
- * return Promise.resolve();
686
- * }, target)
687
- * }
688
- * }
689
- * @param {AppEvent} eventName
690
- * @param {EventHookFunc} eventFunc
691
- * @param {any} target
692
- * @return {*}
693
- */
694
- function BindEventHook(eventName, eventFunc, target) {
695
- 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);
696
444
  }
697
- /**
698
- * execute bootstrap
699
- *
700
- * @param {*} target
701
- * @param {Function} bootFunc
702
- * @param {boolean} [isInitiative=false] Whether to actively execute app instantiation,
703
- * mainly for unittest scenarios, you need to actively obtain app instances
704
- * @returns {Promise<void>}
705
- */
706
- const executeBootstrap = async function (target, bootFunc, isInitiative = false) {
707
- // checked runtime
708
- checkRuntime();
709
- // unittest running environment
710
- const isUTRuntime = checkUTRuntime();
711
- if (!isInitiative && isUTRuntime) {
712
- return;
713
- }
714
- const app = Reflect.construct(target, []);
715
- // unittest does not print startup logs
716
- if (isUTRuntime) {
717
- app.silent = true;
718
- Logger.enable(false);
719
- }
720
- try {
721
- if (!app.silent)
722
- Logger.Log("Koatty", LOGO);
723
- if (!(app instanceof koatty_core.Koatty)) {
724
- throw new Error(`class ${target.name} does not inherit from Koatty`);
725
- }
726
- // Initialize env
727
- Loader.initialize(app);
728
- // exec bootFunc
729
- if (koatty_lib.Helper.isFunction(bootFunc)) {
730
- Logger.Log('Koatty', '', 'Execute bootFunc ...');
731
- await bootFunc(app);
732
- }
733
- // Set IOC.app
734
- koatty_container.IOC.setApp(app);
735
- // Check all bean
736
- Logger.Log('Koatty', '', 'ComponentScan ...');
737
- Loader.CheckAllComponents(app, target);
738
- // Load App event hooks
739
- Loader.LoadAppEventHooks(app, target);
740
- Logger.Log('Koatty', '', 'Emit App Boot ...');
741
- await asyncEvent(app, "appBoot" /* AppEvent.appBoot */);
742
- // Load All components
743
- await Loader.LoadAllComponents(app, target);
744
- // Emit app ready event
745
- Logger.Log('Koatty', '', 'Emit App Ready ...');
746
- await asyncEvent(app, "appReady" /* AppEvent.appReady */);
747
- if (!isUTRuntime) {
748
- // Start Server
749
- app.listen(listenCallback);
750
- }
751
- return app;
752
- }
753
- catch (err) {
754
- Logger.Error(err);
755
- process.exit();
756
- }
757
- };
758
- /**
759
- * Listening callback function
760
- *
761
- * @param {Koatty} app
762
- * @returns {*}
763
- */
764
- const listenCallback = (app) => {
765
- let servers = [];
766
- if (!Array.isArray(app.server)) {
767
- servers = [app.server];
768
- }
769
- else {
770
- 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);
771
462
  }
772
- Logger.Log('Koatty', '', '====================================');
773
- Logger.Log("Koatty", "", `Nodejs Version: ${process.version}`);
774
- Logger.Log("Koatty", "", `Koatty Version: v${KOATTY_VERSION}`);
775
- Logger.Log("Koatty", "", `App Environment: ${app.env}`);
776
- servers.forEach(s => {
777
- Logger.Log('Koatty', '', `Server: ${(s.options.protocol).toUpperCase()} running at ${s.options.protocol === "http2" ?
778
- "https" : s.options.protocol}://${s.options.hostname || '127.0.0.1'}:${s.options.port}/`);
779
- });
780
- Logger.Log("Koatty", "", "====================================");
781
- if (app.appDebug)
782
- Logger.Warn(`Running in debug mode.`);
783
- // Set Logger
784
- 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
+ }
785
478
  };
786
- /**
787
- * Execute event as async
788
- *
789
- * @param {Koatty} event
790
- * @param {string} eventName
791
- */
792
- const asyncEvent = async function (event, eventName) {
793
- const ls = event.listeners(eventName);
794
- // eslint-disable-next-line no-restricted-syntax
795
- for await (const func of ls) {
796
- if (koatty_lib.Helper.isFunction(func)) {
797
- func();
798
- }
799
- }
800
- 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);
801
493
  };
802
494
 
803
495
  Object.defineProperty(exports, "Config", {
804
- enumerable: true,
805
- get: function () { return koatty_config.Config; }
496
+ enumerable: !0,
497
+ get: function() {
498
+ return e.Config;
499
+ }
806
500
  });
501
+
807
502
  Object.defineProperty(exports, "Helper", {
808
- enumerable: true,
809
- get: function () { return koatty_lib.Helper; }
503
+ enumerable: !0,
504
+ get: function() {
505
+ return a.Helper;
506
+ }
810
507
  });
811
- exports.BindEventHook = BindEventHook;
812
- exports.Bootstrap = Bootstrap;
813
- exports.ComponentScan = ComponentScan;
814
- exports.ConfigurationScan = ConfigurationScan;
815
- exports.ExecBootStrap = ExecBootStrap;
816
- exports.Logger = Logger;
817
- Object.keys(koatty_container).forEach(function (k) {
818
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
819
- enumerable: true,
820
- 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
+ }
821
527
  });
822
- });
823
- Object.keys(koatty_core).forEach(function (k) {
824
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
825
- enumerable: true,
826
- 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
+ }
827
536
  });
828
- });
829
- Object.keys(koatty_exception).forEach(function (k) {
830
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
831
- enumerable: true,
832
- 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
+ }
833
545
  });
834
- });
835
- Object.keys(koatty_router).forEach(function (k) {
836
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
837
- enumerable: true,
838
- 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
+ }
839
554
  });
840
- });
555
+ }));