koatty 3.6.4 → 3.6.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
4
4
 
5
+ ### [3.6.5](https://github.com/thinkkoa/koatty/compare/v3.6.4...v3.6.5) (2022-03-02)
6
+
5
7
  ### [3.6.4](https://github.com/thinkkoa/koatty/compare/v3.6.3...v3.6.4) (2022-02-25)
6
8
 
7
9
  ### [3.6.3](https://github.com/thinkkoa/koatty/compare/v3.6.2...v3.6.3) (2022-02-25)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 16:53:03
3
+ * @Date: 2022-03-02 15:39:00
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -74,7 +74,7 @@ export declare class BaseController implements IController {
74
74
  * @returns {*}
75
75
  * @memberof BaseController
76
76
  */
77
- fail(msg: Error | string | ApiInput, data?: any, code?: number): any;
77
+ fail(msg: Error | string | ApiInput, data?: any, code?: number): void;
78
78
  }
79
79
 
80
80
  /**
@@ -268,10 +268,10 @@ export declare class HttpController extends BaseController {
268
268
  * @param {*} data
269
269
  * @param {string} [contentType]
270
270
  * @param {string} [encoding]
271
- * @returns {Promise<any>}
271
+ * @returns void
272
272
  * @memberof HttpController
273
273
  */
274
- body(data: any, contentType?: string, encoding?: string): Promise<any>;
274
+ body(data: any, contentType?: string, encoding?: string): void;
275
275
  /**
276
276
  * Respond to json formatted content
277
277
  *
@@ -279,27 +279,7 @@ export declare class HttpController extends BaseController {
279
279
  * @returns {Promise<any>}
280
280
  * @memberof HttpController
281
281
  */
282
- json(data: any): Promise<any>;
283
- /**
284
- * Response to normalize json format content for success
285
- *
286
- * @param {(string | ApiInput)} msg 待处理的message消息
287
- * @param {*} [data] 待处理的数据
288
- * @param {number} [code=200] 错误码,默认0
289
- * @returns {*}
290
- * @memberof HttpController
291
- */
292
- ok(msg: string | ApiInput, data?: any, code?: number): Promise<any>;
293
- /**
294
- * Response to normalize json format content for fail
295
- *
296
- * @param {(string | ApiInput)} msg
297
- * @param {*} [data]
298
- * @param {number} [code=1]
299
- * @returns {*}
300
- * @memberof HttpController
301
- */
302
- fail(msg: Error | string | ApiInput, data?: any, code?: number): Promise<any>;
282
+ json(data: any): void;
303
283
  }
304
284
 
305
285
  /**
@@ -310,8 +290,8 @@ export declare interface IController {
310
290
  readonly ctx: KoattyContext;
311
291
  __befor?: () => Promise<any>;
312
292
  __after?: () => Promise<any>;
313
- readonly fail: (msg?: Error | string | ApiInput, data?: any, ret?: number) => Promise<any>;
314
293
  readonly ok: (msg?: string | ApiInput, data?: any, ret?: number) => Promise<any>;
294
+ readonly fail: (msg?: Error | string | ApiInput, data?: any, ret?: number) => void;
315
295
  }
316
296
 
317
297
  /**
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 16:52:45
3
+ * @Date: 2022-03-02 15:38:40
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -195,7 +195,7 @@ class BaseController {
195
195
  */
196
196
  fail(msg, data, code = 1) {
197
197
  const obj = formatApiData(msg, data, code);
198
- return Promise.resolve(obj);
198
+ this.ctx.throw(obj.message, obj.code, 200);
199
199
  }
200
200
  }
201
201
  // const properties = ["constructor", "init"];
@@ -359,7 +359,7 @@ class HttpController extends BaseController {
359
359
  * @param {*} data
360
360
  * @param {string} [contentType]
361
361
  * @param {string} [encoding]
362
- * @returns {Promise<any>}
362
+ * @returns void
363
363
  * @memberof HttpController
364
364
  */
365
365
  body(data, contentType, encoding) {
@@ -379,32 +379,6 @@ class HttpController extends BaseController {
379
379
  json(data) {
380
380
  return this.body(data, "application/json");
381
381
  }
382
- /**
383
- * Response to normalize json format content for success
384
- *
385
- * @param {(string | ApiInput)} msg 待处理的message消息
386
- * @param {*} [data] 待处理的数据
387
- * @param {number} [code=200] 错误码,默认0
388
- * @returns {*}
389
- * @memberof HttpController
390
- */
391
- ok(msg, data, code = 0) {
392
- const obj = formatApiData(msg, data, code);
393
- return this.json(obj);
394
- }
395
- /**
396
- * Response to normalize json format content for fail
397
- *
398
- * @param {(string | ApiInput)} msg
399
- * @param {*} [data]
400
- * @param {number} [code=1]
401
- * @returns {*}
402
- * @memberof HttpController
403
- */
404
- fail(msg, data, code = 1) {
405
- const obj = formatApiData(msg, data, code);
406
- return this.json(obj);
407
- }
408
382
  }
409
383
  // const properties = ["constructor", "init"];
410
384
  // export const HttpController = new Proxy(Base, {
@@ -516,14 +490,13 @@ class Loader {
516
490
  * @memberof Loader
517
491
  */
518
492
  static initialize(app) {
519
- var _a, _b;
520
- const env = ((_a = process.execArgv) !== null && _a !== void 0 ? _a : []).join(",");
493
+ const env = (process.execArgv ?? []).join(",");
521
494
  if (env.indexOf('ts-node') > -1 || env.indexOf('--debug') > -1) {
522
495
  app.appDebug = true;
523
496
  }
524
497
  // app.env
525
498
  app.env = process.env.KOATTY_ENV || process.env.NODE_ENV;
526
- if ((env.indexOf('--production') > -1) || (((_b = app.env) !== null && _b !== void 0 ? _b : '').indexOf('pro') > -1)) {
499
+ if ((env.indexOf('--production') > -1) || ((app.env ?? '').indexOf('pro') > -1)) {
527
500
  app.appDebug = false;
528
501
  }
529
502
  if (app.appDebug) {
@@ -627,8 +600,7 @@ class Loader {
627
600
  * @memberof Loader
628
601
  */
629
602
  static SetLogger(app) {
630
- var _a;
631
- const configs = (_a = app.getMetaData("_configs")) !== null && _a !== void 0 ? _a : {};
603
+ const configs = app.getMetaData("_configs") ?? {};
632
604
  //Logger
633
605
  if (configs.config) {
634
606
  const opt = configs.config;
@@ -704,7 +676,6 @@ class Loader {
704
676
  * @memberof Loader
705
677
  */
706
678
  static async LoadMiddlewares(app, loadPath) {
707
- var _a;
708
679
  let middlewareConf = app.config(undefined, "middleware");
709
680
  if (koatty_lib.Helper.isEmpty(middlewareConf)) {
710
681
  middlewareConf = { config: {}, list: [] };
@@ -713,12 +684,11 @@ class Loader {
713
684
  koatty_loader.Load(loadPath || ["./middleware"], app.thinkPath);
714
685
  //Mount application middleware
715
686
  // const middleware: any = {};
716
- const appMiddleware = (_a = koatty_container.IOCContainer.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
687
+ const appMiddleware = koatty_container.IOCContainer.listClass("MIDDLEWARE") ?? [];
717
688
  appMiddleware.push({ id: "TraceMiddleware", target: TraceMiddleware });
718
689
  appMiddleware.push({ id: "PayloadMiddleware", target: PayloadMiddleware });
719
690
  appMiddleware.forEach((item) => {
720
- var _a;
721
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
691
+ item.id = (item.id ?? "").replace("MIDDLEWARE:", "");
722
692
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
723
693
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
724
694
  }
@@ -776,8 +746,7 @@ class Loader {
776
746
  const controllerList = koatty_container.IOCContainer.listClass("CONTROLLER");
777
747
  const controllers = {};
778
748
  controllerList.forEach((item) => {
779
- var _a;
780
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
749
+ item.id = (item.id ?? "").replace("CONTROLLER:", "");
781
750
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
782
751
  Logger.Debug(`Load controller: ${item.id}`);
783
752
  // registering to IOC
@@ -801,8 +770,7 @@ class Loader {
801
770
  static LoadServices(app) {
802
771
  const serviceList = koatty_container.IOCContainer.listClass("SERVICE");
803
772
  serviceList.forEach((item) => {
804
- var _a;
805
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
773
+ item.id = (item.id ?? "").replace("SERVICE:", "");
806
774
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
807
775
  Logger.Debug(`Load service: ${item.id}`);
808
776
  // registering to IOC
@@ -820,8 +788,7 @@ class Loader {
820
788
  static LoadComponents(app) {
821
789
  const componentList = koatty_container.IOCContainer.listClass("COMPONENT");
822
790
  componentList.forEach((item) => {
823
- var _a;
824
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
791
+ item.id = (item.id ?? "").replace("COMPONENT:", "");
825
792
  if (item.id && !(item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
826
793
  Logger.Debug(`Load component: ${item.id}`);
827
794
  // registering to IOC
@@ -837,7 +804,6 @@ class Loader {
837
804
  * @memberof Loader
838
805
  */
839
806
  static async LoadPlugins(app) {
840
- var _a;
841
807
  const componentList = koatty_container.IOCContainer.listClass("COMPONENT");
842
808
  let pluginsConf = app.config(undefined, "plugin");
843
809
  if (koatty_lib.Helper.isEmpty(pluginsConf)) {
@@ -845,8 +811,7 @@ class Loader {
845
811
  }
846
812
  const pluginList = [];
847
813
  componentList.forEach(async (item) => {
848
- var _a;
849
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
814
+ item.id = (item.id ?? "").replace("COMPONENT:", "");
850
815
  if (item.id && (item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
851
816
  // registering to IOC
852
817
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
@@ -867,12 +832,12 @@ class Loader {
867
832
  continue;
868
833
  }
869
834
  // sync exec
870
- await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
835
+ await handle.run(pluginsConf.config[key] ?? {}, app);
871
836
  }
872
837
  }
873
838
  }
874
839
 
875
- var version = "3.6.4";
840
+ var version = "3.6.5";
876
841
  var engines = {
877
842
  node: ">12.0.0"
878
843
  };
@@ -1026,9 +991,8 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
1026
991
  * @returns {*}
1027
992
  */
1028
993
  const newRouter = function (app) {
1029
- var _a;
1030
994
  const protocol = app.config("protocol") || "http";
1031
- const options = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
995
+ const options = app.config(undefined, 'router') ?? {};
1032
996
  const router = koatty_router.NewRouter(app, options, protocol);
1033
997
  koatty_lib.Helper.define(app, "router", router);
1034
998
  return router;
@@ -1058,12 +1022,11 @@ const listenCallback = (app, options) => {
1058
1022
  * @returns {*}
1059
1023
  */
1060
1024
  const newServe = function (app) {
1061
- var _a, _b, _c;
1062
1025
  const protocol = app.config("protocol") || "http";
1063
1026
  const port = process.env.PORT || process.env.APP_PORT ||
1064
1027
  app.config('app_port') || 3000;
1065
1028
  const hostname = process.env.IP ||
1066
- ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || app.config('app_host') || '127.0.0.1';
1029
+ process.env.HOSTNAME?.replace(/-/g, '.') || app.config('app_host') || '127.0.0.1';
1067
1030
  const options = {
1068
1031
  hostname,
1069
1032
  port,
@@ -1076,8 +1039,8 @@ const newServe = function (app) {
1076
1039
  };
1077
1040
  const pm = new Set(["https", "http2", "wss"]);
1078
1041
  if (pm.has(options.protocol)) {
1079
- const keyFile = (_b = app.config("key_file")) !== null && _b !== void 0 ? _b : "";
1080
- const crtFile = (_c = app.config("crt_file")) !== null && _c !== void 0 ? _c : "";
1042
+ const keyFile = app.config("key_file") ?? "";
1043
+ const crtFile = app.config("crt_file") ?? "";
1081
1044
  options.ext.key = fs__default["default"].readFileSync(keyFile).toString();
1082
1045
  options.ext.cert = fs__default["default"].readFileSync(crtFile).toString();
1083
1046
  }
@@ -1150,7 +1113,7 @@ function ComponentScan(scanPath) {
1150
1113
  if (!(target.prototype instanceof koatty_core.Koatty)) {
1151
1114
  throw new Error(`class does not inherit from Koatty`);
1152
1115
  }
1153
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1116
+ scanPath = scanPath ?? '';
1154
1117
  koatty_container.IOCContainer.saveClassMetadata(koatty_container.TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
1155
1118
  };
1156
1119
  }
@@ -1166,7 +1129,7 @@ function ConfigurationScan(scanPath) {
1166
1129
  if (!(target.prototype instanceof koatty_core.Koatty)) {
1167
1130
  throw new Error(`class does not inherit from Koatty`);
1168
1131
  }
1169
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1132
+ scanPath = scanPath ?? '';
1170
1133
  koatty_container.IOCContainer.saveClassMetadata(koatty_container.TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
1171
1134
  };
1172
1135
  }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-02-25 16:52:45
3
+ * @Date: 2022-03-02 15:38:40
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -175,7 +175,7 @@ class BaseController {
175
175
  */
176
176
  fail(msg, data, code = 1) {
177
177
  const obj = formatApiData(msg, data, code);
178
- return Promise.resolve(obj);
178
+ this.ctx.throw(obj.message, obj.code, 200);
179
179
  }
180
180
  }
181
181
  // const properties = ["constructor", "init"];
@@ -339,7 +339,7 @@ class HttpController extends BaseController {
339
339
  * @param {*} data
340
340
  * @param {string} [contentType]
341
341
  * @param {string} [encoding]
342
- * @returns {Promise<any>}
342
+ * @returns void
343
343
  * @memberof HttpController
344
344
  */
345
345
  body(data, contentType, encoding) {
@@ -359,32 +359,6 @@ class HttpController extends BaseController {
359
359
  json(data) {
360
360
  return this.body(data, "application/json");
361
361
  }
362
- /**
363
- * Response to normalize json format content for success
364
- *
365
- * @param {(string | ApiInput)} msg 待处理的message消息
366
- * @param {*} [data] 待处理的数据
367
- * @param {number} [code=200] 错误码,默认0
368
- * @returns {*}
369
- * @memberof HttpController
370
- */
371
- ok(msg, data, code = 0) {
372
- const obj = formatApiData(msg, data, code);
373
- return this.json(obj);
374
- }
375
- /**
376
- * Response to normalize json format content for fail
377
- *
378
- * @param {(string | ApiInput)} msg
379
- * @param {*} [data]
380
- * @param {number} [code=1]
381
- * @returns {*}
382
- * @memberof HttpController
383
- */
384
- fail(msg, data, code = 1) {
385
- const obj = formatApiData(msg, data, code);
386
- return this.json(obj);
387
- }
388
362
  }
389
363
  // const properties = ["constructor", "init"];
390
364
  // export const HttpController = new Proxy(Base, {
@@ -496,14 +470,13 @@ class Loader {
496
470
  * @memberof Loader
497
471
  */
498
472
  static initialize(app) {
499
- var _a, _b;
500
- const env = ((_a = process.execArgv) !== null && _a !== void 0 ? _a : []).join(",");
473
+ const env = (process.execArgv ?? []).join(",");
501
474
  if (env.indexOf('ts-node') > -1 || env.indexOf('--debug') > -1) {
502
475
  app.appDebug = true;
503
476
  }
504
477
  // app.env
505
478
  app.env = process.env.KOATTY_ENV || process.env.NODE_ENV;
506
- if ((env.indexOf('--production') > -1) || (((_b = app.env) !== null && _b !== void 0 ? _b : '').indexOf('pro') > -1)) {
479
+ if ((env.indexOf('--production') > -1) || ((app.env ?? '').indexOf('pro') > -1)) {
507
480
  app.appDebug = false;
508
481
  }
509
482
  if (app.appDebug) {
@@ -607,8 +580,7 @@ class Loader {
607
580
  * @memberof Loader
608
581
  */
609
582
  static SetLogger(app) {
610
- var _a;
611
- const configs = (_a = app.getMetaData("_configs")) !== null && _a !== void 0 ? _a : {};
583
+ const configs = app.getMetaData("_configs") ?? {};
612
584
  //Logger
613
585
  if (configs.config) {
614
586
  const opt = configs.config;
@@ -684,7 +656,6 @@ class Loader {
684
656
  * @memberof Loader
685
657
  */
686
658
  static async LoadMiddlewares(app, loadPath) {
687
- var _a;
688
659
  let middlewareConf = app.config(undefined, "middleware");
689
660
  if (Helper.isEmpty(middlewareConf)) {
690
661
  middlewareConf = { config: {}, list: [] };
@@ -693,12 +664,11 @@ class Loader {
693
664
  Load(loadPath || ["./middleware"], app.thinkPath);
694
665
  //Mount application middleware
695
666
  // const middleware: any = {};
696
- const appMiddleware = (_a = IOCContainer.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
667
+ const appMiddleware = IOCContainer.listClass("MIDDLEWARE") ?? [];
697
668
  appMiddleware.push({ id: "TraceMiddleware", target: TraceMiddleware });
698
669
  appMiddleware.push({ id: "PayloadMiddleware", target: PayloadMiddleware });
699
670
  appMiddleware.forEach((item) => {
700
- var _a;
701
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
671
+ item.id = (item.id ?? "").replace("MIDDLEWARE:", "");
702
672
  if (item.id && Helper.isClass(item.target)) {
703
673
  IOCContainer.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
704
674
  }
@@ -756,8 +726,7 @@ class Loader {
756
726
  const controllerList = IOCContainer.listClass("CONTROLLER");
757
727
  const controllers = {};
758
728
  controllerList.forEach((item) => {
759
- var _a;
760
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
729
+ item.id = (item.id ?? "").replace("CONTROLLER:", "");
761
730
  if (item.id && Helper.isClass(item.target)) {
762
731
  Logger.Debug(`Load controller: ${item.id}`);
763
732
  // registering to IOC
@@ -781,8 +750,7 @@ class Loader {
781
750
  static LoadServices(app) {
782
751
  const serviceList = IOCContainer.listClass("SERVICE");
783
752
  serviceList.forEach((item) => {
784
- var _a;
785
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
753
+ item.id = (item.id ?? "").replace("SERVICE:", "");
786
754
  if (item.id && Helper.isClass(item.target)) {
787
755
  Logger.Debug(`Load service: ${item.id}`);
788
756
  // registering to IOC
@@ -800,8 +768,7 @@ class Loader {
800
768
  static LoadComponents(app) {
801
769
  const componentList = IOCContainer.listClass("COMPONENT");
802
770
  componentList.forEach((item) => {
803
- var _a;
804
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
771
+ item.id = (item.id ?? "").replace("COMPONENT:", "");
805
772
  if (item.id && !(item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
806
773
  Logger.Debug(`Load component: ${item.id}`);
807
774
  // registering to IOC
@@ -817,7 +784,6 @@ class Loader {
817
784
  * @memberof Loader
818
785
  */
819
786
  static async LoadPlugins(app) {
820
- var _a;
821
787
  const componentList = IOCContainer.listClass("COMPONENT");
822
788
  let pluginsConf = app.config(undefined, "plugin");
823
789
  if (Helper.isEmpty(pluginsConf)) {
@@ -825,8 +791,7 @@ class Loader {
825
791
  }
826
792
  const pluginList = [];
827
793
  componentList.forEach(async (item) => {
828
- var _a;
829
- item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
794
+ item.id = (item.id ?? "").replace("COMPONENT:", "");
830
795
  if (item.id && (item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
831
796
  // registering to IOC
832
797
  IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
@@ -847,12 +812,12 @@ class Loader {
847
812
  continue;
848
813
  }
849
814
  // sync exec
850
- await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
815
+ await handle.run(pluginsConf.config[key] ?? {}, app);
851
816
  }
852
817
  }
853
818
  }
854
819
 
855
- var version = "3.6.4";
820
+ var version = "3.6.5";
856
821
  var engines = {
857
822
  node: ">12.0.0"
858
823
  };
@@ -1006,9 +971,8 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
1006
971
  * @returns {*}
1007
972
  */
1008
973
  const newRouter = function (app) {
1009
- var _a;
1010
974
  const protocol = app.config("protocol") || "http";
1011
- const options = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
975
+ const options = app.config(undefined, 'router') ?? {};
1012
976
  const router = NewRouter(app, options, protocol);
1013
977
  Helper.define(app, "router", router);
1014
978
  return router;
@@ -1038,12 +1002,11 @@ const listenCallback = (app, options) => {
1038
1002
  * @returns {*}
1039
1003
  */
1040
1004
  const newServe = function (app) {
1041
- var _a, _b, _c;
1042
1005
  const protocol = app.config("protocol") || "http";
1043
1006
  const port = process.env.PORT || process.env.APP_PORT ||
1044
1007
  app.config('app_port') || 3000;
1045
1008
  const hostname = process.env.IP ||
1046
- ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || app.config('app_host') || '127.0.0.1';
1009
+ process.env.HOSTNAME?.replace(/-/g, '.') || app.config('app_host') || '127.0.0.1';
1047
1010
  const options = {
1048
1011
  hostname,
1049
1012
  port,
@@ -1056,8 +1019,8 @@ const newServe = function (app) {
1056
1019
  };
1057
1020
  const pm = new Set(["https", "http2", "wss"]);
1058
1021
  if (pm.has(options.protocol)) {
1059
- const keyFile = (_b = app.config("key_file")) !== null && _b !== void 0 ? _b : "";
1060
- const crtFile = (_c = app.config("crt_file")) !== null && _c !== void 0 ? _c : "";
1022
+ const keyFile = app.config("key_file") ?? "";
1023
+ const crtFile = app.config("crt_file") ?? "";
1061
1024
  options.ext.key = fs.readFileSync(keyFile).toString();
1062
1025
  options.ext.cert = fs.readFileSync(crtFile).toString();
1063
1026
  }
@@ -1130,7 +1093,7 @@ function ComponentScan(scanPath) {
1130
1093
  if (!(target.prototype instanceof Koatty)) {
1131
1094
  throw new Error(`class does not inherit from Koatty`);
1132
1095
  }
1133
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1096
+ scanPath = scanPath ?? '';
1134
1097
  IOCContainer.saveClassMetadata(TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
1135
1098
  };
1136
1099
  }
@@ -1146,7 +1109,7 @@ function ConfigurationScan(scanPath) {
1146
1109
  if (!(target.prototype instanceof Koatty)) {
1147
1110
  throw new Error(`class does not inherit from Koatty`);
1148
1111
  }
1149
- scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1112
+ scanPath = scanPath ?? '';
1150
1113
  IOCContainer.saveClassMetadata(TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
1151
1114
  };
1152
1115
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.6.4",
3
+ "version": "3.6.5",
4
4
  "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -80,9 +80,9 @@
80
80
  "dependencies": {
81
81
  "koa": "2.13.4",
82
82
  "koatty_config": "1.1.2",
83
- "koatty_container": "1.7.6",
83
+ "koatty_container": "1.7.7",
84
84
  "koatty_core": "1.6.1",
85
- "koatty_exception": "1.2.2",
85
+ "koatty_exception": "1.2.4",
86
86
  "koatty_lib": "1.2.10",
87
87
  "koatty_loader": "1.0.2",
88
88
  "koatty_logger": "1.3.12",
@@ -90,7 +90,7 @@
90
90
  "koatty_proto": "1.1.6",
91
91
  "koatty_router": "1.7.2",
92
92
  "koatty_serve": "1.4.8",
93
- "koatty_trace": "1.6.1",
93
+ "koatty_trace": "1.6.4",
94
94
  "koatty_validation": "1.2.2",
95
95
  "reflect-metadata": "0.1.13",
96
96
  "tslib": "2.3.1"
@@ -1 +1 @@
1
- window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":0,"numPassedTests":0,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":0,"numTotalTests":0,"startTime":1645779159740,"success":false,"testResults":[],"wasInterrupted":false,"config":{"bail":0,"changedFilesWithAncestor":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"coverage","coverageProvider":"babel","coverageReporters":["html","lcov","json","text","clover","text-summary"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"passWithNoTests":true,"projects":[],"reporters":[["default",{}],["/Users/richen/Workspace/nodejs/koatty/node_modules/jest-html-reporters/index.js",{}]],"rootDir":"/Users/richen/Workspace/nodejs/koatty","runTestsByPath":false,"skipFilter":false,"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/Users/richen/Workspace/nodejs/koatty/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"watch":false,"watchAll":false,"watchman":true},"endTime":1645779159899,"_reporterOptions":{"publicPath":"/Users/richen/Workspace/nodejs/koatty","filename":"jest_html_reporters.html","expand":false,"pageTitle":"","hideIcon":false,"testCommand":"npx jest","openReport":false,"failureMessageOnly":false,"enableMergeData":false,"dataMergeLevel":1},"attachInfos":{}})
1
+ window.jest_html_reporters_callback__({"numFailedTestSuites":0,"numFailedTests":0,"numPassedTestSuites":0,"numPassedTests":0,"numPendingTestSuites":0,"numPendingTests":0,"numRuntimeErrorTestSuites":0,"numTodoTests":0,"numTotalTestSuites":0,"numTotalTests":0,"startTime":1646206717841,"success":false,"testResults":[],"wasInterrupted":false,"config":{"bail":0,"changedFilesWithAncestor":false,"collectCoverage":true,"collectCoverageFrom":[],"coverageDirectory":"coverage","coverageProvider":"babel","coverageReporters":["html","lcov","json","text","clover","text-summary"],"detectLeaks":false,"detectOpenHandles":false,"errorOnDeprecated":false,"expand":false,"findRelatedTests":false,"forceExit":false,"json":false,"lastCommit":false,"listTests":false,"logHeapUsage":false,"maxConcurrency":5,"maxWorkers":7,"noStackTrace":false,"nonFlagArgs":[],"notify":false,"notifyMode":"failure-change","onlyChanged":false,"onlyFailures":false,"passWithNoTests":true,"projects":[],"reporters":[["default",{}],["/Users/richen/Workspace/nodejs/koatty/node_modules/jest-html-reporters/index.js",{}]],"rootDir":"/Users/richen/Workspace/nodejs/koatty","runTestsByPath":false,"skipFilter":false,"testFailureExitCode":1,"testPathPattern":"","testSequencer":"/Users/richen/Workspace/nodejs/koatty/node_modules/@jest/test-sequencer/build/index.js","updateSnapshot":"new","useStderr":false,"watch":false,"watchAll":false,"watchman":true},"endTime":1646206718115,"_reporterOptions":{"publicPath":"/Users/richen/Workspace/nodejs/koatty","filename":"jest_html_reporters.html","expand":false,"pageTitle":"","hideIcon":false,"testCommand":"npx jest","openReport":false,"failureMessageOnly":false,"enableMergeData":false,"dataMergeLevel":1},"attachInfos":{}})
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.6.4",
3
+ "version": "3.6.5",
4
4
  "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
5
  "scripts": {
6
6
  "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
@@ -80,9 +80,9 @@
80
80
  "dependencies": {
81
81
  "koa": "2.13.4",
82
82
  "koatty_config": "1.1.2",
83
- "koatty_container": "1.7.6",
83
+ "koatty_container": "1.7.7",
84
84
  "koatty_core": "1.6.1",
85
- "koatty_exception": "1.2.2",
85
+ "koatty_exception": "1.2.4",
86
86
  "koatty_lib": "1.2.10",
87
87
  "koatty_loader": "1.0.2",
88
88
  "koatty_logger": "1.3.12",
@@ -90,7 +90,7 @@
90
90
  "koatty_proto": "1.1.6",
91
91
  "koatty_router": "1.7.2",
92
92
  "koatty_serve": "1.4.8",
93
- "koatty_trace": "1.6.1",
93
+ "koatty_trace": "1.6.4",
94
94
  "koatty_validation": "1.2.2",
95
95
  "reflect-metadata": "0.1.13",
96
96
  "tslib": "2.3.1"