koatty 3.5.12-3 → 3.5.16

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,12 @@
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.5.16](https://github.com/thinkkoa/koatty/compare/v3.5.14...v3.5.16) (2022-02-14)
6
+
7
+ ### [3.5.14](https://github.com/thinkkoa/koatty/compare/v3.5.12...v3.5.14) (2022-01-17)
8
+
9
+ ### [3.5.12](https://github.com/thinkkoa/koatty/compare/v3.5.12-3...v3.5.12) (2021-12-23)
10
+
5
11
  ### [3.5.12-3](https://github.com/thinkkoa/koatty/compare/v3.5.12-2...v3.5.12-3) (2021-12-23)
6
12
 
7
13
  ### [3.5.12-2](https://github.com/thinkkoa/koatty/compare/v3.5.12-1...v3.5.12-2) (2021-12-21)
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2021-12-23 15:26:28
3
+ * @Date: 2022-02-14 14:58:36
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -10,7 +10,6 @@ import { Koatty } from 'koatty_core';
10
10
  import { KoattyContext } from 'koatty_core';
11
11
  import { KoattyNext } from 'koatty_core';
12
12
  import { Logger as Logger_2 } from 'koatty_logger';
13
- import { ObjectDefinitionOptions } from 'koatty_container';
14
13
 
15
14
  /**
16
15
  * Interface for Api input
@@ -40,7 +39,7 @@ export declare type AppReadyHookFunc = (app: Koatty) => Promise<any>;
40
39
  * @implements {IController}
41
40
  */
42
41
  export declare class BaseController implements IController {
43
- app: Koatty;
42
+ readonly app: Koatty;
44
43
  readonly ctx: KoattyContext;
45
44
  /**
46
45
  * instance of BaseController.
@@ -83,18 +82,18 @@ export declare class BaseController implements IController {
83
82
  * @class Base
84
83
  */
85
84
  export declare class BaseService implements IService {
86
- app: Koatty;
85
+ readonly app: Koatty;
87
86
  /**
88
- * instance of Base.
89
- * @param {...any[]} arg
90
- * @memberof Base
87
+ * instance of BaseController.
88
+ * @param {Koatty} app
89
+ * @param {KoattyContext} ctx
90
+ * @memberof BaseController
91
91
  */
92
92
  /**
93
93
  * init
94
94
  *
95
95
  * @protected
96
- * @param {...any[]} arg
97
- * @memberof Base
96
+ * @memberof BaseController
98
97
  */
99
98
  }
100
99
 
@@ -294,7 +293,7 @@ export declare class HttpController extends BaseController {
294
293
  * Interface for Controller
295
294
  */
296
295
  export declare interface IController {
297
- app: Koatty;
296
+ readonly app: Koatty;
298
297
  readonly ctx: KoattyContext;
299
298
  __befor?: () => Promise<any>;
300
299
  __after?: () => Promise<any>;
@@ -320,7 +319,7 @@ export declare interface IPlugin {
320
319
  * Interface for Service
321
320
  */
322
321
  export declare interface IService {
323
- app: Koatty;
322
+ readonly app: Koatty;
324
323
  }
325
324
 
326
325
  /**
@@ -334,7 +333,7 @@ export declare const Logger: Logger_2;
334
333
  * Indicates that an decorated class is a "middleware".
335
334
  *
336
335
  * @export
337
- * @param {string} [identifier] middleware name
336
+ * @param {string} [identifier] class name
338
337
  * @returns {ClassDecorator}
339
338
  */
340
339
  export declare function Middleware(identifier?: string): ClassDecorator;
@@ -343,7 +342,7 @@ export declare function Middleware(identifier?: string): ClassDecorator;
343
342
  * Indicates that an decorated class is a "plugin".
344
343
  *
345
344
  * @export
346
- * @param {string} [identifier]
345
+ * @param {string} [identifier] class name
347
346
  * @returns {ClassDecorator}
348
347
  */
349
348
  export declare function Plugin(identifier?: string): ClassDecorator;
@@ -352,7 +351,7 @@ export declare function Plugin(identifier?: string): ClassDecorator;
352
351
  * Indicates that an decorated class is a "service".
353
352
  *
354
353
  * @export
355
- * @param {string} [identifier] middleware name
354
+ * @param {string} [identifier] class name
356
355
  * @returns {ClassDecorator}
357
356
  */
358
357
  export declare function Service(identifier?: string): ClassDecorator;
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2021-12-23 15:26:13
3
+ * @Date: 2022-02-14 14:58:23
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -136,9 +136,9 @@ class BaseController {
136
136
  * @param {KoattyContext} ctx
137
137
  * @memberof BaseController
138
138
  */
139
- constructor(ctx) {
139
+ constructor(ctx, ...arg) {
140
140
  this.ctx = ctx;
141
- this.init();
141
+ this.init(arg);
142
142
  }
143
143
  /**
144
144
  * init
@@ -146,10 +146,10 @@ class BaseController {
146
146
  * @protected
147
147
  * @memberof BaseController
148
148
  */
149
- init() {
149
+ init(...arg) {
150
150
  }
151
151
  // /**
152
- // * Class pre-execution method, executed before each class member methods (except constructor, init, __after) are executed.
152
+ // * Class pre-execution method (except constructor, init, __after).
153
153
  // *
154
154
  // * @returns {Promise<any>}
155
155
  // * @memberof BaseController
@@ -158,7 +158,7 @@ class BaseController {
158
158
  // return Promise.resolve();
159
159
  // }
160
160
  // /**
161
- // * Class after-execution method,after each class member methods (except constructor, init, __before) are executed.
161
+ // * Class after-execution method (except constructor, init, __before).
162
162
  // *
163
163
  // * @public
164
164
  // * @returns {*}
@@ -462,34 +462,6 @@ function SetLogger(config) {
462
462
  }
463
463
  }
464
464
 
465
- /**
466
- * Base class
467
- *
468
- * @export
469
- * @class Base
470
- */
471
- class BaseService {
472
- /**
473
- * instance of Base.
474
- * @param {...any[]} arg
475
- * @memberof Base
476
- */
477
- constructor(...arg) {
478
- this.init(arg);
479
- }
480
- /**
481
- * init
482
- *
483
- * @protected
484
- * @param {...any[]} arg
485
- * @memberof Base
486
- */
487
- init(...arg) {
488
- // todo
489
- // Logger.Debug(arg)
490
- }
491
- }
492
-
493
465
  /**
494
466
  * @ author: richen
495
467
  * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
@@ -830,10 +802,6 @@ class Loader {
830
802
  Logger.Debug(`Load service: ${item.id}`);
831
803
  // registering to IOC
832
804
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "SERVICE", args: [] });
833
- const ctl = koatty_container.IOCContainer.getInsByClass(item.target);
834
- if (!(ctl instanceof BaseService)) {
835
- throw new Error(`class ${item.id} does not inherit from BaseService`);
836
- }
837
805
  }
838
806
  });
839
807
  }
@@ -851,8 +819,6 @@ class Loader {
851
819
  item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
852
820
  if (item.id && !(item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
853
821
  Logger.Debug(`Load component: ${item.id}`);
854
- // inject schedule
855
- // injectSchedule(item.target, item.target.prototype, IOCContainer);
856
822
  // registering to IOC
857
823
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
858
824
  }
@@ -877,7 +843,6 @@ class Loader {
877
843
  var _a;
878
844
  item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
879
845
  if (item.id && (item.id).endsWith("Plugin") && koatty_lib.Helper.isClass(item.target)) {
880
- // Logger.Debug(`Load plugin: ${item.id}`);
881
846
  // registering to IOC
882
847
  koatty_container.IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
883
848
  pluginList.push(item.id);
@@ -896,14 +861,13 @@ class Loader {
896
861
  if (pluginsConf.config[key] === false) {
897
862
  continue;
898
863
  }
899
- // Logger.Debug(`Execute plugin: ${key}`);
900
864
  // sync exec
901
865
  await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
902
866
  }
903
867
  }
904
868
  }
905
869
 
906
- var version = "3.5.12-3";
870
+ var version = "3.5.16";
907
871
  var engines = {
908
872
  node: ">12.0.0"
909
873
  };
@@ -1171,7 +1135,7 @@ function Controller(path = "") {
1171
1135
  * Indicates that an decorated class is a "middleware".
1172
1136
  *
1173
1137
  * @export
1174
- * @param {string} [identifier] middleware name
1138
+ * @param {string} [identifier] class name
1175
1139
  * @returns {ClassDecorator}
1176
1140
  */
1177
1141
  function Middleware(identifier) {
@@ -1184,7 +1148,7 @@ function Middleware(identifier) {
1184
1148
  * Indicates that an decorated class is a "service".
1185
1149
  *
1186
1150
  * @export
1187
- * @param {string} [identifier] middleware name
1151
+ * @param {string} [identifier] class name
1188
1152
  * @returns {ClassDecorator}
1189
1153
  */
1190
1154
  function Service(identifier) {
@@ -1197,7 +1161,7 @@ function Service(identifier) {
1197
1161
  * Indicates that an decorated class is a "plugin".
1198
1162
  *
1199
1163
  * @export
1200
- * @param {string} [identifier]
1164
+ * @param {string} [identifier] class name
1201
1165
  * @returns {ClassDecorator}
1202
1166
  */
1203
1167
  function Plugin(identifier) {
@@ -1211,6 +1175,32 @@ function Plugin(identifier) {
1211
1175
  };
1212
1176
  }
1213
1177
 
1178
+ /**
1179
+ * Base class
1180
+ *
1181
+ * @export
1182
+ * @class Base
1183
+ */
1184
+ class BaseService {
1185
+ /**
1186
+ * instance of BaseController.
1187
+ * @param {Koatty} app
1188
+ * @param {KoattyContext} ctx
1189
+ * @memberof BaseController
1190
+ */
1191
+ constructor(...arg) {
1192
+ this.init(arg);
1193
+ }
1194
+ /**
1195
+ * init
1196
+ *
1197
+ * @protected
1198
+ * @memberof BaseController
1199
+ */
1200
+ init(...arg) {
1201
+ }
1202
+ }
1203
+
1214
1204
  Object.defineProperty(exports, 'Helper', {
1215
1205
  enumerable: true,
1216
1206
  get: function () { return koatty_lib.Helper; }
package/dist/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2021-12-23 15:26:13
3
+ * @Date: 2022-02-14 14:58:23
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -119,9 +119,9 @@ class BaseController {
119
119
  * @param {KoattyContext} ctx
120
120
  * @memberof BaseController
121
121
  */
122
- constructor(ctx) {
122
+ constructor(ctx, ...arg) {
123
123
  this.ctx = ctx;
124
- this.init();
124
+ this.init(arg);
125
125
  }
126
126
  /**
127
127
  * init
@@ -129,10 +129,10 @@ class BaseController {
129
129
  * @protected
130
130
  * @memberof BaseController
131
131
  */
132
- init() {
132
+ init(...arg) {
133
133
  }
134
134
  // /**
135
- // * Class pre-execution method, executed before each class member methods (except constructor, init, __after) are executed.
135
+ // * Class pre-execution method (except constructor, init, __after).
136
136
  // *
137
137
  // * @returns {Promise<any>}
138
138
  // * @memberof BaseController
@@ -141,7 +141,7 @@ class BaseController {
141
141
  // return Promise.resolve();
142
142
  // }
143
143
  // /**
144
- // * Class after-execution method,after each class member methods (except constructor, init, __before) are executed.
144
+ // * Class after-execution method (except constructor, init, __before).
145
145
  // *
146
146
  // * @public
147
147
  // * @returns {*}
@@ -445,34 +445,6 @@ function SetLogger(config) {
445
445
  }
446
446
  }
447
447
 
448
- /**
449
- * Base class
450
- *
451
- * @export
452
- * @class Base
453
- */
454
- class BaseService {
455
- /**
456
- * instance of Base.
457
- * @param {...any[]} arg
458
- * @memberof Base
459
- */
460
- constructor(...arg) {
461
- this.init(arg);
462
- }
463
- /**
464
- * init
465
- *
466
- * @protected
467
- * @param {...any[]} arg
468
- * @memberof Base
469
- */
470
- init(...arg) {
471
- // todo
472
- // Logger.Debug(arg)
473
- }
474
- }
475
-
476
448
  /**
477
449
  * @ author: richen
478
450
  * @ copyright: Copyright (c) - <richenlin(at)gmail.com>
@@ -813,10 +785,6 @@ class Loader {
813
785
  Logger.Debug(`Load service: ${item.id}`);
814
786
  // registering to IOC
815
787
  IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "SERVICE", args: [] });
816
- const ctl = IOCContainer.getInsByClass(item.target);
817
- if (!(ctl instanceof BaseService)) {
818
- throw new Error(`class ${item.id} does not inherit from BaseService`);
819
- }
820
788
  }
821
789
  });
822
790
  }
@@ -834,8 +802,6 @@ class Loader {
834
802
  item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
835
803
  if (item.id && !(item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
836
804
  Logger.Debug(`Load component: ${item.id}`);
837
- // inject schedule
838
- // injectSchedule(item.target, item.target.prototype, IOCContainer);
839
805
  // registering to IOC
840
806
  IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
841
807
  }
@@ -860,7 +826,6 @@ class Loader {
860
826
  var _a;
861
827
  item.id = ((_a = item.id) !== null && _a !== void 0 ? _a : "").replace("COMPONENT:", "");
862
828
  if (item.id && (item.id).endsWith("Plugin") && Helper.isClass(item.target)) {
863
- // Logger.Debug(`Load plugin: ${item.id}`);
864
829
  // registering to IOC
865
830
  IOCContainer.reg(item.id, item.target, { scope: "Singleton", type: "COMPONENT", args: [] });
866
831
  pluginList.push(item.id);
@@ -879,14 +844,13 @@ class Loader {
879
844
  if (pluginsConf.config[key] === false) {
880
845
  continue;
881
846
  }
882
- // Logger.Debug(`Execute plugin: ${key}`);
883
847
  // sync exec
884
848
  await handle.run((_a = pluginsConf.config[key]) !== null && _a !== void 0 ? _a : {}, app);
885
849
  }
886
850
  }
887
851
  }
888
852
 
889
- var version = "3.5.12-3";
853
+ var version = "3.5.16";
890
854
  var engines = {
891
855
  node: ">12.0.0"
892
856
  };
@@ -1154,7 +1118,7 @@ function Controller(path = "") {
1154
1118
  * Indicates that an decorated class is a "middleware".
1155
1119
  *
1156
1120
  * @export
1157
- * @param {string} [identifier] middleware name
1121
+ * @param {string} [identifier] class name
1158
1122
  * @returns {ClassDecorator}
1159
1123
  */
1160
1124
  function Middleware(identifier) {
@@ -1167,7 +1131,7 @@ function Middleware(identifier) {
1167
1131
  * Indicates that an decorated class is a "service".
1168
1132
  *
1169
1133
  * @export
1170
- * @param {string} [identifier] middleware name
1134
+ * @param {string} [identifier] class name
1171
1135
  * @returns {ClassDecorator}
1172
1136
  */
1173
1137
  function Service(identifier) {
@@ -1180,7 +1144,7 @@ function Service(identifier) {
1180
1144
  * Indicates that an decorated class is a "plugin".
1181
1145
  *
1182
1146
  * @export
1183
- * @param {string} [identifier]
1147
+ * @param {string} [identifier] class name
1184
1148
  * @returns {ClassDecorator}
1185
1149
  */
1186
1150
  function Plugin(identifier) {
@@ -1194,4 +1158,30 @@ function Plugin(identifier) {
1194
1158
  };
1195
1159
  }
1196
1160
 
1161
+ /**
1162
+ * Base class
1163
+ *
1164
+ * @export
1165
+ * @class Base
1166
+ */
1167
+ class BaseService {
1168
+ /**
1169
+ * instance of BaseController.
1170
+ * @param {Koatty} app
1171
+ * @param {KoattyContext} ctx
1172
+ * @memberof BaseController
1173
+ */
1174
+ constructor(...arg) {
1175
+ this.init(arg);
1176
+ }
1177
+ /**
1178
+ * init
1179
+ *
1180
+ * @protected
1181
+ * @memberof BaseController
1182
+ */
1183
+ init(...arg) {
1184
+ }
1185
+ }
1186
+
1197
1187
  export { BaseController, BaseService, BindAppReadyHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, HttpController, Logger, Middleware, Plugin, Service };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.5.12-3",
3
+ "version": "3.5.16",
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",
@@ -83,15 +83,15 @@
83
83
  "koa": "^2.13.4",
84
84
  "koatty_config": "^1.0.6",
85
85
  "koatty_container": "^1.6.16",
86
- "koatty_core": "^1.4.14",
87
- "koatty_exception": "^1.0.6",
86
+ "koatty_core": "^1.5.2",
87
+ "koatty_exception": "^1.1.2",
88
88
  "koatty_lib": "^1.2.8",
89
89
  "koatty_loader": "^1.0.2",
90
90
  "koatty_logger": "^1.3.12",
91
- "koatty_payload": "^1.3.10",
91
+ "koatty_payload": "^1.3.11",
92
92
  "koatty_router": "^1.6.4",
93
93
  "koatty_serve": "^1.4.4",
94
- "koatty_trace": "^1.5.2",
94
+ "koatty_trace": "^1.5.4",
95
95
  "reflect-metadata": "^0.1.13",
96
96
  "tslib": "^2.3.1"
97
97
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.5.12-3",
3
+ "version": "3.5.16",
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",
@@ -83,15 +83,15 @@
83
83
  "koa": "^2.13.4",
84
84
  "koatty_config": "^1.0.6",
85
85
  "koatty_container": "^1.6.16",
86
- "koatty_core": "^1.4.14",
87
- "koatty_exception": "^1.0.6",
86
+ "koatty_core": "^1.5.2",
87
+ "koatty_exception": "^1.1.2",
88
88
  "koatty_lib": "^1.2.8",
89
89
  "koatty_loader": "^1.0.2",
90
90
  "koatty_logger": "^1.3.12",
91
- "koatty_payload": "^1.3.10",
91
+ "koatty_payload": "^1.3.11",
92
92
  "koatty_router": "^1.6.4",
93
93
  "koatty_serve": "^1.4.4",
94
- "koatty_trace": "^1.5.2",
94
+ "koatty_trace": "^1.5.4",
95
95
  "reflect-metadata": "^0.1.13",
96
96
  "tslib": "^2.3.1"
97
97
  }