koatty 3.6.6 → 3.6.8-2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -14,12 +14,28 @@
14
14
  "ts-node/register"
15
15
  ],
16
16
  "env": {
17
- "NODE_ENV": "development",
17
+ "NODE_ENV": "development"
18
18
  },
19
19
  "sourceMaps": true,
20
20
  "cwd": "${workspaceRoot}",
21
21
  "protocol": "inspector",
22
22
  "internalConsoleOptions": "neverOpen"
23
+ },
24
+ {
25
+ "type": "node",
26
+ "name": "vscode-jest-tests",
27
+ "request": "launch",
28
+ "console": "integratedTerminal",
29
+ "internalConsoleOptions": "neverOpen",
30
+ "disableOptimisticBPs": true,
31
+ "program": "${workspaceFolder}/node_modules/.bin/jest",
32
+ "cwd": "${workspaceFolder}",
33
+ "args": [
34
+ "--config",
35
+ "jest.config.js",
36
+ "--runInBand",
37
+ "--watchAll=false"
38
+ ]
23
39
  }
24
40
  ]
25
41
  }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,16 @@
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.8-2](https://github.com/thinkkoa/koatty/compare/v3.6.8-1...v3.6.8-2) (2022-03-15)
6
+
7
+ ### [3.6.8-1](https://github.com/thinkkoa/koatty/compare/v3.6.8-0...v3.6.8-1) (2022-03-15)
8
+
9
+ ### [3.6.8-0](https://github.com/thinkkoa/koatty/compare/v3.6.7...v3.6.8-0) (2022-03-14)
10
+
11
+ ### [3.6.8-0](https://github.com/thinkkoa/koatty/compare/v3.6.7...v3.6.8-0) (2022-03-14)
12
+
13
+ ### [3.6.7](https://github.com/thinkkoa/koatty/compare/v3.6.6...v3.6.7) (2022-03-09)
14
+
5
15
  ### [3.6.6](https://github.com/thinkkoa/koatty/compare/v3.6.5...v3.6.6) (2022-03-02)
6
16
 
7
17
  ### [3.6.5](https://github.com/thinkkoa/koatty/compare/v3.6.4...v3.6.5) (2022-03-02)
package/README.md CHANGED
@@ -103,22 +103,26 @@ export class IndexController extends BaseController {
103
103
  ```javascript
104
104
  import request from 'supertest';
105
105
  import { ExecBootStrap } from 'koatty';
106
-
107
106
  import { App } from '../src/App';
108
107
 
109
108
  describe('UT example', () => {
110
109
 
111
- let server;
110
+ let server: any;
112
111
  beforeAll(async () => {
112
+ jest.useFakeTimers();
113
113
  const appInstance = await ExecBootStrap()(App);
114
- server = appInstance.callback();
114
+ server = await appInstance.listen();
115
115
  });
116
116
 
117
- it('request', async (done) => {
118
- const rsp = await request(server).get('/path/to/server');
119
- expect(rsp.status).toBe(200);
117
+ afterAll(done => {
118
+ server.close();
120
119
  done();
121
120
  });
121
+
122
+ it('request', async () => {
123
+ const rsp = await request(server).get('/');
124
+ expect(rsp.status).toBe(200);
125
+ });
122
126
  });
123
127
 
124
128
  ```
package/dist/README.md CHANGED
@@ -103,22 +103,26 @@ export class IndexController extends BaseController {
103
103
  ```javascript
104
104
  import request from 'supertest';
105
105
  import { ExecBootStrap } from 'koatty';
106
-
107
106
  import { App } from '../src/App';
108
107
 
109
108
  describe('UT example', () => {
110
109
 
111
- let server;
110
+ let server: any;
112
111
  beforeAll(async () => {
112
+ jest.useFakeTimers();
113
113
  const appInstance = await ExecBootStrap()(App);
114
- server = appInstance.callback();
114
+ server = await appInstance.listen();
115
115
  });
116
116
 
117
- it('request', async (done) => {
118
- const rsp = await request(server).get('/path/to/server');
119
- expect(rsp.status).toBe(200);
117
+ afterAll(done => {
118
+ server.close();
120
119
  done();
121
120
  });
121
+
122
+ it('request', async () => {
123
+ const rsp = await request(server).get('/');
124
+ expect(rsp.status).toBe(200);
125
+ });
122
126
  });
123
127
 
124
128
  ```
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-03-02 19:03:06
3
+ * @Date: 2022-03-15 14:27:44
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -171,7 +171,7 @@ export declare function Controller(path?: string): ClassDecorator;
171
171
  * @param {Function} [bootFunc] callback function
172
172
  * @returns
173
173
  */
174
- export declare function ExecBootStrap(bootFunc?: Function): (target: any) => Promise<void>;
174
+ export declare function ExecBootStrap(bootFunc?: Function): (target: any) => Promise<Koatty>;
175
175
 
176
176
  export { Helper }
177
177
 
@@ -225,7 +225,7 @@ export declare class HttpController extends BaseController {
225
225
  * @returns
226
226
  * @memberof HttpController
227
227
  */
228
- param(name?: string): any;
228
+ param(name?: string): Promise<any>;
229
229
  /**
230
230
  * Set response content-type
231
231
  *
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-03-02 19:02:51
3
+ * @Date: 2022-03-15 14:27:23
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -27,21 +27,21 @@ var koatty_payload = require('koatty_payload');
27
27
  function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
28
28
 
29
29
  function _interopNamespace(e) {
30
- if (e && e.__esModule) return e;
31
- var n = Object.create(null);
32
- if (e) {
33
- Object.keys(e).forEach(function (k) {
34
- if (k !== 'default') {
35
- var d = Object.getOwnPropertyDescriptor(e, k);
36
- Object.defineProperty(n, k, d.get ? d : {
37
- enumerable: true,
38
- get: function () { return e[k]; }
39
- });
40
- }
30
+ if (e && e.__esModule) return e;
31
+ var n = Object.create(null);
32
+ if (e) {
33
+ Object.keys(e).forEach(function (k) {
34
+ if (k !== 'default') {
35
+ var d = Object.getOwnPropertyDescriptor(e, k);
36
+ Object.defineProperty(n, k, d.get ? d : {
37
+ enumerable: true,
38
+ get: function () { return e[k]; }
41
39
  });
42
- }
43
- n["default"] = e;
44
- return Object.freeze(n);
40
+ }
41
+ });
42
+ }
43
+ n["default"] = e;
44
+ return Object.freeze(n);
45
45
  }
46
46
 
47
47
  var fs__default = /*#__PURE__*/_interopDefaultLegacy(fs);
@@ -491,13 +491,14 @@ class Loader {
491
491
  * @memberof Loader
492
492
  */
493
493
  static initialize(app) {
494
- const env = (process.execArgv ?? []).join(",");
494
+ var _a, _b;
495
+ const env = ((_a = process.execArgv) !== null && _a !== void 0 ? _a : []).join(",");
495
496
  if (env.indexOf('ts-node') > -1 || env.indexOf('--debug') > -1) {
496
497
  app.appDebug = true;
497
498
  }
498
499
  // app.env
499
500
  app.env = process.env.KOATTY_ENV || process.env.NODE_ENV;
500
- if ((env.indexOf('--production') > -1) || ((app.env ?? '').indexOf('pro') > -1)) {
501
+ if ((env.indexOf('--production') > -1) || (((_b = app.env) !== null && _b !== void 0 ? _b : '').indexOf('pro') > -1)) {
501
502
  app.appDebug = false;
502
503
  }
503
504
  if (app.appDebug) {
@@ -601,7 +602,8 @@ class Loader {
601
602
  * @memberof Loader
602
603
  */
603
604
  static SetLogger(app) {
604
- const configs = app.getMetaData("_configs") ?? {};
605
+ var _a;
606
+ const configs = (_a = app.getMetaData("_configs")) !== null && _a !== void 0 ? _a : {};
605
607
  //Logger
606
608
  if (configs.config) {
607
609
  const opt = configs.config;
@@ -677,6 +679,7 @@ class Loader {
677
679
  * @memberof Loader
678
680
  */
679
681
  static async LoadMiddlewares(app, loadPath) {
682
+ var _a;
680
683
  let middlewareConf = app.config(undefined, "middleware");
681
684
  if (koatty_lib.Helper.isEmpty(middlewareConf)) {
682
685
  middlewareConf = { config: {}, list: [] };
@@ -685,11 +688,12 @@ class Loader {
685
688
  koatty_loader.Load(loadPath || ["./middleware"], app.thinkPath);
686
689
  //Mount application middleware
687
690
  // const middleware: any = {};
688
- const appMiddleware = koatty_container.IOCContainer.listClass("MIDDLEWARE") ?? [];
691
+ const appMiddleware = (_a = koatty_container.IOCContainer.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
689
692
  appMiddleware.push({ id: "TraceMiddleware", target: TraceMiddleware });
690
693
  appMiddleware.push({ id: "PayloadMiddleware", target: PayloadMiddleware });
691
694
  appMiddleware.forEach((item) => {
692
- item.id = (item.id ?? "").replace("MIDDLEWARE:", "");
695
+ var _a;
696
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
693
697
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
694
698
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
695
699
  }
@@ -745,9 +749,10 @@ class Loader {
745
749
  */
746
750
  static LoadControllers(app) {
747
751
  const controllerList = koatty_container.IOCContainer.listClass("CONTROLLER");
748
- const controllers = {};
752
+ const controllers = [];
749
753
  controllerList.forEach((item) => {
750
- item.id = (item.id ?? "").replace("CONTROLLER:", "");
754
+ var _a;
755
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
751
756
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
752
757
  Logger.Debug(`Load controller: ${item.id}`);
753
758
  // registering to IOC
@@ -756,10 +761,10 @@ class Loader {
756
761
  if (!(ctl instanceof BaseController)) {
757
762
  throw new Error(`class ${item.id} does not inherit from BaseController`);
758
763
  }
759
- controllers[item.id] = 1;
764
+ controllers.push(item.id);
760
765
  }
761
766
  });
762
- app.setMetaData("_controllers", controllers);
767
+ return controllers;
763
768
  }
764
769
  /**
765
770
  * Load services
@@ -771,7 +776,8 @@ class Loader {
771
776
  static LoadServices(app) {
772
777
  const serviceList = koatty_container.IOCContainer.listClass("SERVICE");
773
778
  serviceList.forEach((item) => {
774
- item.id = (item.id ?? "").replace("SERVICE:", "");
779
+ var _a;
780
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
775
781
  if (item.id && koatty_lib.Helper.isClass(item.target)) {
776
782
  Logger.Debug(`Load service: ${item.id}`);
777
783
  // registering to IOC
@@ -789,7 +795,8 @@ class Loader {
789
795
  static LoadComponents(app) {
790
796
  const componentList = koatty_container.IOCContainer.listClass("COMPONENT");
791
797
  componentList.forEach((item) => {
792
- item.id = (item.id ?? "").replace("COMPONENT:", "");
798
+ var _a;
799
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
793
800
  if (item.id && !(item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
794
801
  Logger.Debug(`Load component: ${item.id}`);
795
802
  // registering to IOC
@@ -805,6 +812,7 @@ class Loader {
805
812
  * @memberof Loader
806
813
  */
807
814
  static async LoadPlugins(app) {
815
+ var _a;
808
816
  const componentList = koatty_container.IOCContainer.listClass("COMPONENT");
809
817
  let pluginsConf = app.config(undefined, "plugin");
810
818
  if (koatty_lib.Helper.isEmpty(pluginsConf)) {
@@ -812,7 +820,8 @@ class Loader {
812
820
  }
813
821
  const pluginList = [];
814
822
  componentList.forEach(async (item) => {
815
- item.id = (item.id ?? "").replace("COMPONENT:", "");
823
+ var _a;
824
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
816
825
  if (item.id && (item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
817
826
  // registering to IOC
818
827
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
@@ -833,12 +842,12 @@ class Loader {
833
842
  continue;
834
843
  }
835
844
  // sync exec
836
- await handle.run(pluginsConf.config[key] ?? {}, app);
845
+ await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
837
846
  }
838
847
  }
839
848
  }
840
849
 
841
- var version = "3.6.6";
850
+ var version = "3.6.8-2";
842
851
  var engines = {
843
852
  node: ">12.0.0"
844
853
  };
@@ -848,7 +857,7 @@ var engines = {
848
857
  * @Usage:
849
858
  * @Author: richen
850
859
  * @Date: 2021-12-17 11:54:06
851
- * @LastEditTime: 2022-02-23 16:12:34
860
+ * @LastEditTime: 2022-03-15 14:22:45
852
861
  */
853
862
  const KOATTY_VERSION = version;
854
863
  const ENGINES_VERSION = engines.node.slice(1) || '12.0.0';
@@ -949,6 +958,10 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
949
958
  Loader.LoadAppReadyHooks(app, target);
950
959
  // New router
951
960
  const KoattyRouter = newRouter(app);
961
+ koatty_lib.Helper.define(app, "router", KoattyRouter);
962
+ // Create Server
963
+ app.server = newServe(app);
964
+ koatty_lib.Helper.define(app, "listenCallback", listenCallback(app));
952
965
  // Load Middleware
953
966
  Logger.Log('think', '', 'Load Middlewares ...');
954
967
  await Loader.LoadMiddlewares(app);
@@ -960,24 +973,17 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
960
973
  Loader.LoadServices(app);
961
974
  // Load Controllers
962
975
  Logger.Log('think', '', 'Load Controllers ...');
963
- Loader.LoadControllers(app);
976
+ const controllers = Loader.LoadControllers(app);
977
+ // Load Routers
978
+ Logger.Log('think', '', 'Load Routers ...');
979
+ KoattyRouter.LoadRouter(controllers);
964
980
  // Emit app ready event
965
981
  Logger.Log('think', '', 'Emit App Ready ...');
966
- // app.emit("appReady");
967
982
  await asyncEvent(app, 'appReady');
968
- // Load Routers
969
- Logger.Log('think', '', 'Load Routers ...');
970
- KoattyRouter.LoadRouter(app.getMetaData("_controllers"));
971
- Logger.Log('think', '', '====================================');
972
- // Start server
973
- const server = newServe(app);
974
- app.listen(server, listenCallback(app, server.options));
975
- // app.emit("appStart");
976
- // Emit app started event
977
- Logger.Log('think', '', 'Emit App Start ...');
978
- asyncEvent(app, 'appStart');
979
- // binding event "appStop"
980
- koatty_serve.BindProcessEvent(app, 'appStop');
983
+ if (!isUTRuntime) {
984
+ app.listen();
985
+ }
986
+ return app;
981
987
  }
982
988
  catch (err) {
983
989
  Logger.Error(err);
@@ -992,26 +998,34 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
992
998
  * @returns {*}
993
999
  */
994
1000
  const newRouter = function (app) {
1001
+ var _a;
995
1002
  const protocol = app.config("protocol") || "http";
996
- const options = app.config(undefined, 'router') ?? {};
1003
+ const options = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
997
1004
  const router = koatty_router.NewRouter(app, options, protocol);
998
- koatty_lib.Helper.define(app, "router", router);
999
1005
  return router;
1000
1006
  };
1001
1007
  /**
1002
1008
  * Listening callback function
1003
1009
  *
1004
1010
  * @param {Koatty} app
1005
- * @param {ListeningOptions} options
1006
1011
  * @returns {*}
1007
1012
  */
1008
- const listenCallback = (app, options) => {
1013
+ const listenCallback = (app) => {
1014
+ const options = app.server.options;
1009
1015
  return function () {
1016
+ // Emit app started event
1017
+ Logger.Log('think', '', 'Emit App Start ...');
1018
+ asyncEvent(app, 'appStart');
1019
+ Logger.Log('think', '', '====================================');
1010
1020
  Logger.Log("think", "", `Nodejs Version: ${process.version}`);
1011
1021
  Logger.Log("think", "", `Koatty Version: v${app.version}`);
1012
1022
  Logger.Log("think", "", `App Environment: ${app.env}`);
1023
+ Logger.Log('think', '', `Server Protocol: ${(options.protocol).toUpperCase()}`);
1013
1024
  Logger.Log("think", "", `Server running at ${options.protocol === "http2" ? "https" : options.protocol}://${options.hostname || '127.0.0.1'}:${options.port}/`);
1014
1025
  Logger.Log("think", "", "====================================");
1026
+ // binding event "appStop"
1027
+ Logger.Log('think', '', 'Bind App Stop event ...');
1028
+ koatty_serve.BindProcessEvent(app, 'appStop');
1015
1029
  // tslint:disable-next-line: no-unused-expression
1016
1030
  app.appDebug && Logger.Warn(`Running in debug mode.`);
1017
1031
  };
@@ -1023,11 +1037,12 @@ const listenCallback = (app, options) => {
1023
1037
  * @returns {*}
1024
1038
  */
1025
1039
  const newServe = function (app) {
1040
+ var _a, _b, _c;
1026
1041
  const protocol = app.config("protocol") || "http";
1027
1042
  const port = process.env.PORT || process.env.APP_PORT ||
1028
1043
  app.config('app_port') || 3000;
1029
1044
  const hostname = process.env.IP ||
1030
- process.env.HOSTNAME?.replace(/-/g, '.') || app.config('app_host') || '127.0.0.1';
1045
+ ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || app.config('app_host') || '127.0.0.1';
1031
1046
  const options = {
1032
1047
  hostname,
1033
1048
  port,
@@ -1040,8 +1055,8 @@ const newServe = function (app) {
1040
1055
  };
1041
1056
  const pm = new Set(["https", "http2", "wss"]);
1042
1057
  if (pm.has(options.protocol)) {
1043
- const keyFile = app.config("key_file") ?? "";
1044
- const crtFile = app.config("crt_file") ?? "";
1058
+ const keyFile = (_b = app.config("key_file")) !== null && _b !== void 0 ? _b : "";
1059
+ const crtFile = (_c = app.config("crt_file")) !== null && _c !== void 0 ? _c : "";
1045
1060
  options.ext.key = fs__default["default"].readFileSync(keyFile).toString();
1046
1061
  options.ext.cert = fs__default["default"].readFileSync(crtFile).toString();
1047
1062
  }
@@ -1052,9 +1067,7 @@ const newServe = function (app) {
1052
1067
  const proto = app.config("protoFile", "router");
1053
1068
  options.ext.protoFile = proto;
1054
1069
  }
1055
- const server = koatty_serve.Serve(app, options);
1056
- koatty_lib.Helper.define(app, "server", server);
1057
- return server;
1070
+ return koatty_serve.Serve(app, options);
1058
1071
  };
1059
1072
  /**
1060
1073
  * Execute event as async
@@ -1114,7 +1127,7 @@ function ComponentScan(scanPath) {
1114
1127
  if (!(target.prototype instanceof koatty_core.Koatty)) {
1115
1128
  throw new Error(`class does not inherit from Koatty`);
1116
1129
  }
1117
- scanPath = scanPath ?? '';
1130
+ scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1118
1131
  koatty_container.IOCContainer.saveClassMetadata(koatty_container.TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
1119
1132
  };
1120
1133
  }
@@ -1130,7 +1143,7 @@ function ConfigurationScan(scanPath) {
1130
1143
  if (!(target.prototype instanceof koatty_core.Koatty)) {
1131
1144
  throw new Error(`class does not inherit from Koatty`);
1132
1145
  }
1133
- scanPath = scanPath ?? '';
1146
+ scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1134
1147
  koatty_container.IOCContainer.saveClassMetadata(koatty_container.TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
1135
1148
  };
1136
1149
  }
@@ -1258,16 +1271,16 @@ class BaseService {
1258
1271
  }
1259
1272
 
1260
1273
  Object.defineProperty(exports, 'Helper', {
1261
- enumerable: true,
1262
- get: function () { return koatty_lib.Helper; }
1274
+ enumerable: true,
1275
+ get: function () { return koatty_lib.Helper; }
1263
1276
  });
1264
1277
  Object.defineProperty(exports, 'Config', {
1265
- enumerable: true,
1266
- get: function () { return koatty_config.Config; }
1278
+ enumerable: true,
1279
+ get: function () { return koatty_config.Config; }
1267
1280
  });
1268
1281
  Object.defineProperty(exports, 'Value', {
1269
- enumerable: true,
1270
- get: function () { return koatty_config.Value; }
1282
+ enumerable: true,
1283
+ get: function () { return koatty_config.Value; }
1271
1284
  });
1272
1285
  exports.BaseController = BaseController;
1273
1286
  exports.BaseService = BaseService;
@@ -1284,32 +1297,32 @@ exports.Middleware = Middleware;
1284
1297
  exports.Plugin = Plugin;
1285
1298
  exports.Service = Service;
1286
1299
  Object.keys(koatty_core).forEach(function (k) {
1287
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1288
- enumerable: true,
1289
- get: function () { return koatty_core[k]; }
1290
- });
1300
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1301
+ enumerable: true,
1302
+ get: function () { return koatty_core[k]; }
1303
+ });
1291
1304
  });
1292
1305
  Object.keys(koatty_router).forEach(function (k) {
1293
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1294
- enumerable: true,
1295
- get: function () { return koatty_router[k]; }
1296
- });
1306
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1307
+ enumerable: true,
1308
+ get: function () { return koatty_router[k]; }
1309
+ });
1297
1310
  });
1298
1311
  Object.keys(koatty_container).forEach(function (k) {
1299
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1300
- enumerable: true,
1301
- get: function () { return koatty_container[k]; }
1302
- });
1312
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1313
+ enumerable: true,
1314
+ get: function () { return koatty_container[k]; }
1315
+ });
1303
1316
  });
1304
1317
  Object.keys(koatty_serve).forEach(function (k) {
1305
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1306
- enumerable: true,
1307
- get: function () { return koatty_serve[k]; }
1308
- });
1318
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1319
+ enumerable: true,
1320
+ get: function () { return koatty_serve[k]; }
1321
+ });
1309
1322
  });
1310
1323
  Object.keys(koatty_exception).forEach(function (k) {
1311
- if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1312
- enumerable: true,
1313
- get: function () { return koatty_exception[k]; }
1314
- });
1324
+ if (k !== 'default' && !exports.hasOwnProperty(k)) Object.defineProperty(exports, k, {
1325
+ enumerable: true,
1326
+ get: function () { return koatty_exception[k]; }
1327
+ });
1315
1328
  });
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2022-03-02 19:02:51
3
+ * @Date: 2022-03-15 14:27:23
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -15,7 +15,7 @@ import { NewRouter, CONTROLLER_ROUTER } from 'koatty_router';
15
15
  export * from 'koatty_router';
16
16
  import { IOCContainer, TAGGED_CLS } from 'koatty_container';
17
17
  export * from 'koatty_container';
18
- import { BindProcessEvent, Serve } from 'koatty_serve';
18
+ import { Serve, BindProcessEvent } from 'koatty_serve';
19
19
  export * from 'koatty_serve';
20
20
  import * as path from 'path';
21
21
  import { Load } from 'koatty_loader';
@@ -471,13 +471,14 @@ class Loader {
471
471
  * @memberof Loader
472
472
  */
473
473
  static initialize(app) {
474
- const env = (process.execArgv ?? []).join(",");
474
+ var _a, _b;
475
+ const env = ((_a = process.execArgv) !== null && _a !== void 0 ? _a : []).join(",");
475
476
  if (env.indexOf('ts-node') > -1 || env.indexOf('--debug') > -1) {
476
477
  app.appDebug = true;
477
478
  }
478
479
  // app.env
479
480
  app.env = process.env.KOATTY_ENV || process.env.NODE_ENV;
480
- if ((env.indexOf('--production') > -1) || ((app.env ?? '').indexOf('pro') > -1)) {
481
+ if ((env.indexOf('--production') > -1) || (((_b = app.env) !== null && _b !== void 0 ? _b : '').indexOf('pro') > -1)) {
481
482
  app.appDebug = false;
482
483
  }
483
484
  if (app.appDebug) {
@@ -581,7 +582,8 @@ class Loader {
581
582
  * @memberof Loader
582
583
  */
583
584
  static SetLogger(app) {
584
- const configs = app.getMetaData("_configs") ?? {};
585
+ var _a;
586
+ const configs = (_a = app.getMetaData("_configs")) !== null && _a !== void 0 ? _a : {};
585
587
  //Logger
586
588
  if (configs.config) {
587
589
  const opt = configs.config;
@@ -657,6 +659,7 @@ class Loader {
657
659
  * @memberof Loader
658
660
  */
659
661
  static async LoadMiddlewares(app, loadPath) {
662
+ var _a;
660
663
  let middlewareConf = app.config(undefined, "middleware");
661
664
  if (Helper.isEmpty(middlewareConf)) {
662
665
  middlewareConf = { config: {}, list: [] };
@@ -665,11 +668,12 @@ class Loader {
665
668
  Load(loadPath || ["./middleware"], app.thinkPath);
666
669
  //Mount application middleware
667
670
  // const middleware: any = {};
668
- const appMiddleware = IOCContainer.listClass("MIDDLEWARE") ?? [];
671
+ const appMiddleware = (_a = IOCContainer.listClass("MIDDLEWARE")) !== null && _a !== void 0 ? _a : [];
669
672
  appMiddleware.push({ id: "TraceMiddleware", target: TraceMiddleware });
670
673
  appMiddleware.push({ id: "PayloadMiddleware", target: PayloadMiddleware });
671
674
  appMiddleware.forEach((item) => {
672
- item.id = (item.id ?? "").replace("MIDDLEWARE:", "");
675
+ var _a;
676
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("MIDDLEWARE:", "");
673
677
  if (item.id && Helper.isClass(item.target)) {
674
678
  IOCContainer.reg(item.id, item.target, { scope: "Prototype", type: "MIDDLEWARE", args: [] });
675
679
  }
@@ -725,9 +729,10 @@ class Loader {
725
729
  */
726
730
  static LoadControllers(app) {
727
731
  const controllerList = IOCContainer.listClass("CONTROLLER");
728
- const controllers = {};
732
+ const controllers = [];
729
733
  controllerList.forEach((item) => {
730
- item.id = (item.id ?? "").replace("CONTROLLER:", "");
734
+ var _a;
735
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("CONTROLLER:", "");
731
736
  if (item.id && Helper.isClass(item.target)) {
732
737
  Logger.Debug(`Load controller: ${item.id}`);
733
738
  // registering to IOC
@@ -736,10 +741,10 @@ class Loader {
736
741
  if (!(ctl instanceof BaseController)) {
737
742
  throw new Error(`class ${item.id} does not inherit from BaseController`);
738
743
  }
739
- controllers[item.id] = 1;
744
+ controllers.push(item.id);
740
745
  }
741
746
  });
742
- app.setMetaData("_controllers", controllers);
747
+ return controllers;
743
748
  }
744
749
  /**
745
750
  * Load services
@@ -751,7 +756,8 @@ class Loader {
751
756
  static LoadServices(app) {
752
757
  const serviceList = IOCContainer.listClass("SERVICE");
753
758
  serviceList.forEach((item) => {
754
- item.id = (item.id ?? "").replace("SERVICE:", "");
759
+ var _a;
760
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("SERVICE:", "");
755
761
  if (item.id && Helper.isClass(item.target)) {
756
762
  Logger.Debug(`Load service: ${item.id}`);
757
763
  // registering to IOC
@@ -769,7 +775,8 @@ class Loader {
769
775
  static LoadComponents(app) {
770
776
  const componentList = IOCContainer.listClass("COMPONENT");
771
777
  componentList.forEach((item) => {
772
- item.id = (item.id ?? "").replace("COMPONENT:", "");
778
+ var _a;
779
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
773
780
  if (item.id && !(item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
774
781
  Logger.Debug(`Load component: ${item.id}`);
775
782
  // registering to IOC
@@ -785,6 +792,7 @@ class Loader {
785
792
  * @memberof Loader
786
793
  */
787
794
  static async LoadPlugins(app) {
795
+ var _a;
788
796
  const componentList = IOCContainer.listClass("COMPONENT");
789
797
  let pluginsConf = app.config(undefined, "plugin");
790
798
  if (Helper.isEmpty(pluginsConf)) {
@@ -792,7 +800,8 @@ class Loader {
792
800
  }
793
801
  const pluginList = [];
794
802
  componentList.forEach(async (item) => {
795
- item.id = (item.id ?? "").replace("COMPONENT:", "");
803
+ var _a;
804
+ item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
796
805
  if (item.id && (item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
797
806
  // registering to IOC
798
807
  IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
@@ -813,12 +822,12 @@ class Loader {
813
822
  continue;
814
823
  }
815
824
  // sync exec
816
- await handle.run(pluginsConf.config[key] ?? {}, app);
825
+ await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
817
826
  }
818
827
  }
819
828
  }
820
829
 
821
- var version = "3.6.6";
830
+ var version = "3.6.8-2";
822
831
  var engines = {
823
832
  node: ">12.0.0"
824
833
  };
@@ -828,7 +837,7 @@ var engines = {
828
837
  * @Usage:
829
838
  * @Author: richen
830
839
  * @Date: 2021-12-17 11:54:06
831
- * @LastEditTime: 2022-02-23 16:12:34
840
+ * @LastEditTime: 2022-03-15 14:22:45
832
841
  */
833
842
  const KOATTY_VERSION = version;
834
843
  const ENGINES_VERSION = engines.node.slice(1) || '12.0.0';
@@ -929,6 +938,10 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
929
938
  Loader.LoadAppReadyHooks(app, target);
930
939
  // New router
931
940
  const KoattyRouter = newRouter(app);
941
+ Helper.define(app, "router", KoattyRouter);
942
+ // Create Server
943
+ app.server = newServe(app);
944
+ Helper.define(app, "listenCallback", listenCallback(app));
932
945
  // Load Middleware
933
946
  Logger.Log('think', '', 'Load Middlewares ...');
934
947
  await Loader.LoadMiddlewares(app);
@@ -940,24 +953,17 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
940
953
  Loader.LoadServices(app);
941
954
  // Load Controllers
942
955
  Logger.Log('think', '', 'Load Controllers ...');
943
- Loader.LoadControllers(app);
956
+ const controllers = Loader.LoadControllers(app);
957
+ // Load Routers
958
+ Logger.Log('think', '', 'Load Routers ...');
959
+ KoattyRouter.LoadRouter(controllers);
944
960
  // Emit app ready event
945
961
  Logger.Log('think', '', 'Emit App Ready ...');
946
- // app.emit("appReady");
947
962
  await asyncEvent(app, 'appReady');
948
- // Load Routers
949
- Logger.Log('think', '', 'Load Routers ...');
950
- KoattyRouter.LoadRouter(app.getMetaData("_controllers"));
951
- Logger.Log('think', '', '====================================');
952
- // Start server
953
- const server = newServe(app);
954
- app.listen(server, listenCallback(app, server.options));
955
- // app.emit("appStart");
956
- // Emit app started event
957
- Logger.Log('think', '', 'Emit App Start ...');
958
- asyncEvent(app, 'appStart');
959
- // binding event "appStop"
960
- BindProcessEvent(app, 'appStop');
963
+ if (!isUTRuntime) {
964
+ app.listen();
965
+ }
966
+ return app;
961
967
  }
962
968
  catch (err) {
963
969
  Logger.Error(err);
@@ -972,26 +978,34 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
972
978
  * @returns {*}
973
979
  */
974
980
  const newRouter = function (app) {
981
+ var _a;
975
982
  const protocol = app.config("protocol") || "http";
976
- const options = app.config(undefined, 'router') ?? {};
983
+ const options = (_a = app.config(undefined, 'router')) !== null && _a !== void 0 ? _a : {};
977
984
  const router = NewRouter(app, options, protocol);
978
- Helper.define(app, "router", router);
979
985
  return router;
980
986
  };
981
987
  /**
982
988
  * Listening callback function
983
989
  *
984
990
  * @param {Koatty} app
985
- * @param {ListeningOptions} options
986
991
  * @returns {*}
987
992
  */
988
- const listenCallback = (app, options) => {
993
+ const listenCallback = (app) => {
994
+ const options = app.server.options;
989
995
  return function () {
996
+ // Emit app started event
997
+ Logger.Log('think', '', 'Emit App Start ...');
998
+ asyncEvent(app, 'appStart');
999
+ Logger.Log('think', '', '====================================');
990
1000
  Logger.Log("think", "", `Nodejs Version: ${process.version}`);
991
1001
  Logger.Log("think", "", `Koatty Version: v${app.version}`);
992
1002
  Logger.Log("think", "", `App Environment: ${app.env}`);
1003
+ Logger.Log('think', '', `Server Protocol: ${(options.protocol).toUpperCase()}`);
993
1004
  Logger.Log("think", "", `Server running at ${options.protocol === "http2" ? "https" : options.protocol}://${options.hostname || '127.0.0.1'}:${options.port}/`);
994
1005
  Logger.Log("think", "", "====================================");
1006
+ // binding event "appStop"
1007
+ Logger.Log('think', '', 'Bind App Stop event ...');
1008
+ BindProcessEvent(app, 'appStop');
995
1009
  // tslint:disable-next-line: no-unused-expression
996
1010
  app.appDebug && Logger.Warn(`Running in debug mode.`);
997
1011
  };
@@ -1003,11 +1017,12 @@ const listenCallback = (app, options) => {
1003
1017
  * @returns {*}
1004
1018
  */
1005
1019
  const newServe = function (app) {
1020
+ var _a, _b, _c;
1006
1021
  const protocol = app.config("protocol") || "http";
1007
1022
  const port = process.env.PORT || process.env.APP_PORT ||
1008
1023
  app.config('app_port') || 3000;
1009
1024
  const hostname = process.env.IP ||
1010
- process.env.HOSTNAME?.replace(/-/g, '.') || app.config('app_host') || '127.0.0.1';
1025
+ ((_a = process.env.HOSTNAME) === null || _a === void 0 ? void 0 : _a.replace(/-/g, '.')) || app.config('app_host') || '127.0.0.1';
1011
1026
  const options = {
1012
1027
  hostname,
1013
1028
  port,
@@ -1020,8 +1035,8 @@ const newServe = function (app) {
1020
1035
  };
1021
1036
  const pm = new Set(["https", "http2", "wss"]);
1022
1037
  if (pm.has(options.protocol)) {
1023
- const keyFile = app.config("key_file") ?? "";
1024
- const crtFile = app.config("crt_file") ?? "";
1038
+ const keyFile = (_b = app.config("key_file")) !== null && _b !== void 0 ? _b : "";
1039
+ const crtFile = (_c = app.config("crt_file")) !== null && _c !== void 0 ? _c : "";
1025
1040
  options.ext.key = fs.readFileSync(keyFile).toString();
1026
1041
  options.ext.cert = fs.readFileSync(crtFile).toString();
1027
1042
  }
@@ -1032,9 +1047,7 @@ const newServe = function (app) {
1032
1047
  const proto = app.config("protoFile", "router");
1033
1048
  options.ext.protoFile = proto;
1034
1049
  }
1035
- const server = Serve(app, options);
1036
- Helper.define(app, "server", server);
1037
- return server;
1050
+ return Serve(app, options);
1038
1051
  };
1039
1052
  /**
1040
1053
  * Execute event as async
@@ -1094,7 +1107,7 @@ function ComponentScan(scanPath) {
1094
1107
  if (!(target.prototype instanceof Koatty)) {
1095
1108
  throw new Error(`class does not inherit from Koatty`);
1096
1109
  }
1097
- scanPath = scanPath ?? '';
1110
+ scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1098
1111
  IOCContainer.saveClassMetadata(TAGGED_CLS, COMPONENT_SCAN, scanPath, target);
1099
1112
  };
1100
1113
  }
@@ -1110,7 +1123,7 @@ function ConfigurationScan(scanPath) {
1110
1123
  if (!(target.prototype instanceof Koatty)) {
1111
1124
  throw new Error(`class does not inherit from Koatty`);
1112
1125
  }
1113
- scanPath = scanPath ?? '';
1126
+ scanPath = scanPath !== null && scanPath !== void 0 ? scanPath : '';
1114
1127
  IOCContainer.saveClassMetadata(TAGGED_CLS, CONFIGURATION_SCAN, scanPath, target);
1115
1128
  };
1116
1129
  }
package/dist/package.json CHANGED
@@ -1,98 +1,103 @@
1
1
  {
2
- "name": "koatty",
3
- "version": "3.6.6",
4
- "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
- "scripts": {
6
- "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
- "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
- "build:js": "del-cli --force dist && npx rollup -c",
9
- "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
- "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
- "eslint": "eslint --ext .ts,.js ./",
12
- "prepublishOnly": "npm test && npm run build",
13
- "prerelease": "npm test && npm run build",
14
- "release": "standard-version",
15
- "release:pre": "npm run release -- --prerelease",
16
- "release:major": "npm run release -- --release-as major",
17
- "release:minor": "npm run release -- --release-as minor",
18
- "test": "npm run eslint && jest --passWithNoTests",
19
- "test:cov": "jest --collectCoverage --detectOpenHandles",
20
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
21
- },
22
- "main": "./dist/index.js",
23
- "exports": {
24
- "require": "./dist/index.js",
25
- "import": "./dist/index.mjs"
26
- },
27
- "directories": {
28
- "doc": "docs"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/thinkkoa/koatty.git"
33
- },
34
- "engines": {
35
- "node": ">12.0.0"
36
- },
37
- "author": {
38
- "name": "richenlin",
39
- "email": "richenlin@gmail.com"
40
- },
41
- "license": "BSD-3-Clause",
42
- "bugs": {
43
- "url": "https://github.com/thinkkoa/koatty/issues"
44
- },
45
- "homepage": "https://github.com/thinkkoa/koatty",
46
- "maintainers": [
47
- {
48
- "name": "richenlin",
49
- "email": "richenlin@gmail.com"
50
- }
51
- ],
52
- "devDependencies": {
53
- "@microsoft/api-documenter": "^7.x.x",
54
- "@microsoft/api-extractor": "^7.x.x",
55
- "@rollup/plugin-json": "^4.x.x",
56
- "@types/jest": "^27.x.x",
57
- "@types/koa": "^2.x.x",
58
- "@types/koa__router": "^8.x.x",
59
- "@types/node": "^16.x.x",
60
- "@types/ws": "^8.x.x",
61
- "@typescript-eslint/eslint-plugin": "^5.x.x",
62
- "@typescript-eslint/parser": "^5.x.x",
63
- "commitlint": "^11.x.x",
64
- "commitlint-config-gitmoji": "^2.x.x",
65
- "conventional-changelog-cli": "^2.x.x",
66
- "copyfiles": "^2.x.x",
67
- "del-cli": "^4.x.x",
68
- "eslint": "^8.x.x",
69
- "eslint-plugin-jest": "^25.x.x",
70
- "husky": "^4.x.x",
71
- "jest": "^27.x.x",
72
- "jest-html-reporters": "^2.x.x",
73
- "rollup": "^2.x.x",
74
- "rollup-plugin-typescript2": "^0.x.x",
75
- "standard-version": "^9.x.x",
76
- "ts-jest": "^27.x.x",
77
- "ts-node": "^10.x.x",
78
- "typescript": "^4.x.x"
79
- },
80
- "dependencies": {
81
- "koa": "2.13.4",
82
- "koatty_config": "1.1.2",
83
- "koatty_container": "1.7.7",
84
- "koatty_core": "1.6.1",
85
- "koatty_exception": "1.2.6",
86
- "koatty_lib": "1.2.10",
87
- "koatty_loader": "1.0.2",
88
- "koatty_logger": "1.3.12",
89
- "koatty_payload": "1.3.14",
90
- "koatty_proto": "1.1.6",
91
- "koatty_router": "1.7.2",
92
- "koatty_serve": "1.4.8",
93
- "koatty_trace": "1.6.6",
94
- "koatty_validation": "1.2.2",
95
- "reflect-metadata": "0.1.13",
96
- "tslib": "2.3.1"
2
+ "name": "koatty",
3
+ "version": "3.6.8-2",
4
+ "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
+ "scripts": {
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup -c",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
+ "eslint": "eslint --ext .ts,.js ./",
12
+ "prepublishOnly": "npm test && npm run build",
13
+ "prerelease": "npm test && npm run build",
14
+ "release": "standard-version",
15
+ "release:pre": "npm run release -- --prerelease",
16
+ "release:major": "npm run release -- --release-as major",
17
+ "release:minor": "npm run release -- --release-as minor",
18
+ "test": "npm run eslint && jest --passWithNoTests",
19
+ "test:cov": "jest --collectCoverage --detectOpenHandles",
20
+ "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
21
+ },
22
+ "main": "./dist/index.js",
23
+ "exports": {
24
+ "require": "./dist/index.js",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "directories": {
28
+ "doc": "docs"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/thinkkoa/koatty.git"
33
+ },
34
+ "engines": {
35
+ "node": ">12.0.0"
36
+ },
37
+ "author": {
38
+ "name": "richenlin",
39
+ "email": "richenlin@gmail.com"
40
+ },
41
+ "license": "BSD-3-Clause",
42
+ "bugs": {
43
+ "url": "https://github.com/thinkkoa/koatty/issues"
44
+ },
45
+ "homepage": "https://github.com/thinkkoa/koatty",
46
+ "maintainers": [
47
+ {
48
+ "name": "richenlin",
49
+ "email": "richenlin@gmail.com"
97
50
  }
51
+ ],
52
+ "devDependencies": {
53
+ "@commitlint/cli": "^12.x.x",
54
+ "@commitlint/config-conventional": "^15.x.x",
55
+ "@microsoft/api-documenter": "^7.x.x",
56
+ "@microsoft/api-extractor": "^7.x.x",
57
+ "@rollup/plugin-json": "^4.x.x",
58
+ "@types/jest": "^27.x.x",
59
+ "@types/koa": "^2.x.x",
60
+ "@types/koa__router": "^8.x.x",
61
+ "@types/node": "^16.x.x",
62
+ "@types/supertest": "^2.x.x",
63
+ "@types/ws": "^8.x.x",
64
+ "@typescript-eslint/eslint-plugin": "^5.x.x",
65
+ "@typescript-eslint/parser": "^5.x.x",
66
+ "conventional-changelog-cli": "^2.x.x",
67
+ "copyfiles": "^2.x.x",
68
+ "del-cli": "^4.x.x",
69
+ "eslint": "^8.x.x",
70
+ "eslint-plugin-jest": "^25.x.x",
71
+ "husky": "^4.x.x",
72
+ "jest": "^27.x.x",
73
+ "jest-html-reporters": "^2.x.x",
74
+ "koatty_cacheable": "^1.x.x",
75
+ "koatty_schedule": "^1.x.x",
76
+ "koatty_store": "^1.x.x",
77
+ "koatty_validation": "^1.x.x",
78
+ "rollup": "^2.x.x",
79
+ "rollup-plugin-typescript2": "^0.x.x",
80
+ "standard-version": "^9.x.x",
81
+ "supertest": "^6.x.x",
82
+ "ts-jest": "^27.x.x",
83
+ "ts-node": "^10.x.x",
84
+ "typescript": "^4.x.x"
85
+ },
86
+ "dependencies": {
87
+ "koa": "2.13.4",
88
+ "koatty_config": "1.1.2",
89
+ "koatty_container": "1.7.7",
90
+ "koatty_core": "1.6.5",
91
+ "koatty_exception": "1.2.6",
92
+ "koatty_lib": "1.2.10",
93
+ "koatty_loader": "1.0.2",
94
+ "koatty_logger": "1.3.12",
95
+ "koatty_payload": "1.3.16",
96
+ "koatty_proto": "1.1.6",
97
+ "koatty_router": "1.7.5",
98
+ "koatty_serve": "1.4.9",
99
+ "koatty_trace": "1.6.6",
100
+ "reflect-metadata": "0.1.13",
101
+ "tslib": "2.3.1"
102
+ }
98
103
  }
@@ -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":1646218969089,"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":1646218969142,"_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":1647325639576,"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":1647325639968,"_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,98 +1,103 @@
1
1
  {
2
- "name": "koatty",
3
- "version": "3.6.6",
4
- "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
- "scripts": {
6
- "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
- "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
- "build:js": "del-cli --force dist && npx rollup -c",
9
- "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
- "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
- "eslint": "eslint --ext .ts,.js ./",
12
- "prepublishOnly": "npm test && npm run build",
13
- "prerelease": "npm test && npm run build",
14
- "release": "standard-version",
15
- "release:pre": "npm run release -- --prerelease",
16
- "release:major": "npm run release -- --release-as major",
17
- "release:minor": "npm run release -- --release-as minor",
18
- "test": "npm run eslint && jest --passWithNoTests",
19
- "test:cov": "jest --collectCoverage --detectOpenHandles",
20
- "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
21
- },
22
- "main": "./dist/index.js",
23
- "exports": {
24
- "require": "./dist/index.js",
25
- "import": "./dist/index.mjs"
26
- },
27
- "directories": {
28
- "doc": "docs"
29
- },
30
- "repository": {
31
- "type": "git",
32
- "url": "git+https://github.com/thinkkoa/koatty.git"
33
- },
34
- "engines": {
35
- "node": ">12.0.0"
36
- },
37
- "author": {
38
- "name": "richenlin",
39
- "email": "richenlin@gmail.com"
40
- },
41
- "license": "BSD-3-Clause",
42
- "bugs": {
43
- "url": "https://github.com/thinkkoa/koatty/issues"
44
- },
45
- "homepage": "https://github.com/thinkkoa/koatty",
46
- "maintainers": [
47
- {
48
- "name": "richenlin",
49
- "email": "richenlin@gmail.com"
50
- }
51
- ],
52
- "devDependencies": {
53
- "@microsoft/api-documenter": "^7.x.x",
54
- "@microsoft/api-extractor": "^7.x.x",
55
- "@rollup/plugin-json": "^4.x.x",
56
- "@types/jest": "^27.x.x",
57
- "@types/koa": "^2.x.x",
58
- "@types/koa__router": "^8.x.x",
59
- "@types/node": "^16.x.x",
60
- "@types/ws": "^8.x.x",
61
- "@typescript-eslint/eslint-plugin": "^5.x.x",
62
- "@typescript-eslint/parser": "^5.x.x",
63
- "commitlint": "^11.x.x",
64
- "commitlint-config-gitmoji": "^2.x.x",
65
- "conventional-changelog-cli": "^2.x.x",
66
- "copyfiles": "^2.x.x",
67
- "del-cli": "^4.x.x",
68
- "eslint": "^8.x.x",
69
- "eslint-plugin-jest": "^25.x.x",
70
- "husky": "^4.x.x",
71
- "jest": "^27.x.x",
72
- "jest-html-reporters": "^2.x.x",
73
- "rollup": "^2.x.x",
74
- "rollup-plugin-typescript2": "^0.x.x",
75
- "standard-version": "^9.x.x",
76
- "ts-jest": "^27.x.x",
77
- "ts-node": "^10.x.x",
78
- "typescript": "^4.x.x"
79
- },
80
- "dependencies": {
81
- "koa": "2.13.4",
82
- "koatty_config": "1.1.2",
83
- "koatty_container": "1.7.7",
84
- "koatty_core": "1.6.1",
85
- "koatty_exception": "1.2.6",
86
- "koatty_lib": "1.2.10",
87
- "koatty_loader": "1.0.2",
88
- "koatty_logger": "1.3.12",
89
- "koatty_payload": "1.3.14",
90
- "koatty_proto": "1.1.6",
91
- "koatty_router": "1.7.2",
92
- "koatty_serve": "1.4.8",
93
- "koatty_trace": "1.6.6",
94
- "koatty_validation": "1.2.2",
95
- "reflect-metadata": "0.1.13",
96
- "tslib": "2.3.1"
2
+ "name": "koatty",
3
+ "version": "3.6.8-2",
4
+ "description": "Koa2 + Typescript = koatty. Use Typescript's decorator implement auto injection.",
5
+ "scripts": {
6
+ "build": "npm run build:js && npm run build:dts && npm run build:doc && npm run build:cp",
7
+ "build:cp": "node scripts/postBuild && copyfiles package.json LICENSE README.md dist/",
8
+ "build:js": "del-cli --force dist && npx rollup -c",
9
+ "build:doc": "del-cli --force docs/api && npx api-documenter markdown --input temp --output docs/api",
10
+ "build:dts": "del-cli --force temp && npx tsc && npx api-extractor run --local --verbose",
11
+ "eslint": "eslint --ext .ts,.js ./",
12
+ "prepublishOnly": "npm test && npm run build",
13
+ "prerelease": "npm test && npm run build",
14
+ "release": "standard-version",
15
+ "release:pre": "npm run release -- --prerelease",
16
+ "release:major": "npm run release -- --release-as major",
17
+ "release:minor": "npm run release -- --release-as minor",
18
+ "test": "npm run eslint && jest --passWithNoTests",
19
+ "test:cov": "jest --collectCoverage --detectOpenHandles",
20
+ "version": "conventional-changelog -p angular -i CHANGELOG.md -s"
21
+ },
22
+ "main": "./dist/index.js",
23
+ "exports": {
24
+ "require": "./dist/index.js",
25
+ "import": "./dist/index.mjs"
26
+ },
27
+ "directories": {
28
+ "doc": "docs"
29
+ },
30
+ "repository": {
31
+ "type": "git",
32
+ "url": "git+https://github.com/thinkkoa/koatty.git"
33
+ },
34
+ "engines": {
35
+ "node": ">12.0.0"
36
+ },
37
+ "author": {
38
+ "name": "richenlin",
39
+ "email": "richenlin@gmail.com"
40
+ },
41
+ "license": "BSD-3-Clause",
42
+ "bugs": {
43
+ "url": "https://github.com/thinkkoa/koatty/issues"
44
+ },
45
+ "homepage": "https://github.com/thinkkoa/koatty",
46
+ "maintainers": [
47
+ {
48
+ "name": "richenlin",
49
+ "email": "richenlin@gmail.com"
97
50
  }
51
+ ],
52
+ "devDependencies": {
53
+ "@commitlint/cli": "^12.x.x",
54
+ "@commitlint/config-conventional": "^15.x.x",
55
+ "@microsoft/api-documenter": "^7.x.x",
56
+ "@microsoft/api-extractor": "^7.x.x",
57
+ "@rollup/plugin-json": "^4.x.x",
58
+ "@types/jest": "^27.x.x",
59
+ "@types/koa": "^2.x.x",
60
+ "@types/koa__router": "^8.x.x",
61
+ "@types/node": "^16.x.x",
62
+ "@types/supertest": "^2.x.x",
63
+ "@types/ws": "^8.x.x",
64
+ "@typescript-eslint/eslint-plugin": "^5.x.x",
65
+ "@typescript-eslint/parser": "^5.x.x",
66
+ "conventional-changelog-cli": "^2.x.x",
67
+ "copyfiles": "^2.x.x",
68
+ "del-cli": "^4.x.x",
69
+ "eslint": "^8.x.x",
70
+ "eslint-plugin-jest": "^25.x.x",
71
+ "husky": "^4.x.x",
72
+ "jest": "^27.x.x",
73
+ "jest-html-reporters": "^2.x.x",
74
+ "koatty_cacheable": "^1.x.x",
75
+ "koatty_schedule": "^1.x.x",
76
+ "koatty_store": "^1.x.x",
77
+ "koatty_validation": "^1.x.x",
78
+ "rollup": "^2.x.x",
79
+ "rollup-plugin-typescript2": "^0.x.x",
80
+ "standard-version": "^9.x.x",
81
+ "supertest": "^6.x.x",
82
+ "ts-jest": "^27.x.x",
83
+ "ts-node": "^10.x.x",
84
+ "typescript": "^4.x.x"
85
+ },
86
+ "dependencies": {
87
+ "koa": "2.13.4",
88
+ "koatty_config": "1.1.2",
89
+ "koatty_container": "1.7.7",
90
+ "koatty_core": "1.6.5",
91
+ "koatty_exception": "1.2.6",
92
+ "koatty_lib": "1.2.10",
93
+ "koatty_loader": "1.0.2",
94
+ "koatty_logger": "1.3.12",
95
+ "koatty_payload": "1.3.16",
96
+ "koatty_proto": "1.1.6",
97
+ "koatty_router": "1.7.5",
98
+ "koatty_serve": "1.4.9",
99
+ "koatty_trace": "1.6.6",
100
+ "reflect-metadata": "0.1.13",
101
+ "tslib": "2.3.1"
102
+ }
98
103
  }
@@ -0,0 +1,15 @@
1
+ {
2
+ "extends": "./tsconfig.json",
3
+ "compilerOptions": {
4
+ "types": [
5
+ "jest",
6
+ "node"
7
+ ]
8
+ },
9
+ "exclude": [
10
+ "node_modules"
11
+ ],
12
+ "include": [
13
+ "test/*.test.ts"
14
+ ]
15
+ }
@@ -1,3 +0,0 @@
1
- {
2
- "debug.javascript.unmapMissingSources": true
3
- }