koatty 3.9.5 → 3.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ {
2
+ "DevChat.DevChatPath": "/Users/richen/.chat/mamba/envs/devchat/bin/devchat",
3
+ "devchat.defaultModel": "gpt-4"
4
+ }
package/CHANGELOG.md CHANGED
@@ -2,6 +2,20 @@
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.10.0](https://github.com/thinkkoa/koatty/compare/v3.9.5...v3.10.0) (2023-11-08)
6
+
7
+
8
+ ### Features
9
+
10
+ * add app event bind ([66e7a48](https://github.com/thinkkoa/koatty/commit/66e7a488c2aa833e37e1418a9d17c91b0872d255))
11
+ * Custom decorator based on app events ([aa9d96c](https://github.com/thinkkoa/koatty/commit/aa9d96c8bda8364793d868c20eca5d479acb4f88))
12
+
13
+
14
+ ### Bug Fixes
15
+
16
+ * key is null ([d851dc5](https://github.com/thinkkoa/koatty/commit/d851dc525933de9225ddf43bcbedc2ac29922648))
17
+ * readme ([84ed9f4](https://github.com/thinkkoa/koatty/commit/84ed9f4261d9c338c1a70d685f3b44deb35a40ee))
18
+
5
19
  ### [3.9.5](https://github.com/thinkkoa/koatty/compare/v3.9.4...v3.9.5) (2023-09-12)
6
20
 
7
21
 
package/README.md CHANGED
@@ -12,6 +12,7 @@ Use Typescript's decorator implement IOC and AOP.
12
12
  * Support loading environment configuration, parsing command line parameters (process.argv) and environment variables (process.env)
13
13
  * `@ExceptionHandler()` Register global exception handling
14
14
  * graceful shutdown and pre-exit event
15
+ * custom decorator based on app events
15
16
 
16
17
 
17
18
  ## Documentation
package/dist/README.md CHANGED
@@ -12,6 +12,7 @@ Use Typescript's decorator implement IOC and AOP.
12
12
  * Support loading environment configuration, parsing command line parameters (process.argv) and environment variables (process.env)
13
13
  * `@ExceptionHandler()` Register global exception handling
14
14
  * graceful shutdown and pre-exit event
15
+ * custom decorator based on app events
15
16
 
16
17
 
17
18
  ## Documentation
package/dist/index.d.ts CHANGED
@@ -1,11 +1,13 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-09-12 11:22:25
3
+ * @Date: 2023-11-08 15:28:11
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
+ import { AppEvent } from 'koatty_core';
8
9
  import { Config } from 'koatty_config';
10
+ import { EventHookFunc } from 'koatty_core';
9
11
  import { Helper } from 'koatty_lib';
10
12
  import { Koatty } from 'koatty_core';
11
13
  import { KoattyContext } from 'koatty_core';
@@ -31,8 +33,6 @@ export declare interface ApiOutput {
31
33
  data: any;
32
34
  }
33
35
 
34
- export declare type AppBootHookFunc = (app: Koatty) => Promise<any>;
35
-
36
36
  /**
37
37
  * Base controller
38
38
  *
@@ -100,22 +100,22 @@ export declare class BaseService implements IService {
100
100
  }
101
101
 
102
102
  /**
103
- * bind AppBootHookFunc
103
+ * @description: bind App event hook func
104
104
  * example:
105
105
  * export function TestDecorator(): ClassDecorator {
106
106
  * return (target: any) => {
107
- * BindAppBootHook((app: Koatty) => {
107
+ * BindEventHook(AppEvent.appBoot, (app: Koatty) => {
108
108
  * // todo
109
109
  * return Promise.resolve();
110
110
  * }, target)
111
111
  * }
112
112
  * }
113
- *
114
- * @export
115
- * @param {AppBootHookFunc} func
116
- * @param {*} target
113
+ * @param {AppEvent} eventName
114
+ * @param {EventHookFunc} eventFunc
115
+ * @param {any} target
116
+ * @return {*}
117
117
  */
118
- export declare function BindAppBootHook(func: AppBootHookFunc, target: any): void;
118
+ export declare function BindEventHook(eventName: AppEvent, eventFunc: EventHookFunc, target: any): void;
119
119
 
120
120
  /**
121
121
  * Bootstrap application
package/dist/index.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-09-12 11:22:03
3
+ * @Date: 2023-11-08 15:27:56
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
@@ -152,7 +152,6 @@ function formatApiData(msg, data, defaultCode) {
152
152
  */
153
153
  const COMPONENT_SCAN = 'COMPONENT_SCAN';
154
154
  const CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
155
- const APP_BOOT_HOOK = "APP_BOOT_HOOK";
156
155
  // tslint:disable: no-irregular-whitespace
157
156
  const LOGO = `
158
157
 
@@ -294,10 +293,10 @@ class Loader {
294
293
  // define path
295
294
  const rootPath = app.rootPath || process.cwd();
296
295
  const appPath = app.appPath || path__namespace.resolve(rootPath, env.indexOf('ts-node') > -1 ? 'src' : 'dist');
297
- const thinkPath = path__namespace.resolve(__dirname, '..');
296
+ const koattyPath = path__namespace.resolve(__dirname, '..');
298
297
  koatty_lib.Helper.define(app, 'rootPath', rootPath);
299
298
  koatty_lib.Helper.define(app, 'appPath', appPath);
300
- koatty_lib.Helper.define(app, 'thinkPath', thinkPath);
299
+ koatty_lib.Helper.define(app, 'koattyPath', koattyPath);
301
300
  //
302
301
  if (koatty_lib.Helper.isEmpty(app.name)) {
303
302
  const pkg = koatty_lib.Helper.safeRequire(`${path__namespace.dirname(appPath)}/package.json`);
@@ -308,12 +307,11 @@ class Loader {
308
307
  }
309
308
  process.env.ROOT_PATH = rootPath;
310
309
  process.env.APP_PATH = appPath;
311
- process.env.THINK_PATH = thinkPath;
310
+ process.env.KOATTY_PATH = koattyPath;
312
311
  // Compatible with old version, will be deprecated
313
312
  koatty_lib.Helper.define(app, 'prevent', koatty_exception.prevent);
314
- koatty_lib.Helper.define(app, 'root_path', rootPath);
315
- koatty_lib.Helper.define(app, 'app_path', appPath);
316
- koatty_lib.Helper.define(app, 'think_path', thinkPath);
313
+ koatty_lib.Helper.define(app, 'thinkPath', koattyPath);
314
+ process.env.THINK_PATH = koattyPath;
317
315
  }
318
316
  /**
319
317
  * Get component metadata
@@ -411,20 +409,49 @@ class Loader {
411
409
  }
412
410
  }
413
411
  /**
414
- * Load app ready hook funcs
412
+ * Load app event hook funcs
415
413
  *
416
414
  * @static
417
415
  * @param {Koatty} app
418
416
  * @param {*} target
419
417
  * @memberof Loader
420
418
  */
421
- static LoadAppBootHooks(app, target) {
422
- const funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, APP_BOOT_HOOK, target);
423
- if (koatty_lib.Helper.isArray(funcs)) {
424
- funcs.forEach((element) => {
425
- app.once('appBoot', () => element(app));
426
- return null;
427
- });
419
+ static LoadAppEventHooks(app, target) {
420
+ const eventFuncs = new Map();
421
+ for (const event of koatty_core.AppEventArr) {
422
+ let funcs;
423
+ switch (event) {
424
+ case "appBoot" /* AppEvent.appBoot */:
425
+ funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, "appBoot" /* AppEvent.appBoot */, target);
426
+ if (koatty_lib.Helper.isArray(funcs)) {
427
+ eventFuncs.set("appBoot" /* AppEvent.appBoot */, funcs);
428
+ }
429
+ break;
430
+ case "appReady" /* AppEvent.appReady */:
431
+ funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, "appReady" /* AppEvent.appReady */, target);
432
+ if (koatty_lib.Helper.isArray(funcs)) {
433
+ eventFuncs.set("appReady" /* AppEvent.appReady */, funcs);
434
+ }
435
+ break;
436
+ case "appStart" /* AppEvent.appStart */:
437
+ funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, "appStart" /* AppEvent.appStart */, target);
438
+ if (koatty_lib.Helper.isArray(funcs)) {
439
+ eventFuncs.set("appStart" /* AppEvent.appStart */, funcs);
440
+ }
441
+ break;
442
+ case "appStop" /* AppEvent.appStop */:
443
+ funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, "appStop" /* AppEvent.appStop */, target);
444
+ if (koatty_lib.Helper.isArray(funcs)) {
445
+ eventFuncs.set("appStop" /* AppEvent.appStop */, funcs);
446
+ }
447
+ break;
448
+ }
449
+ }
450
+ // loop event emit
451
+ for (const [event, funcs] of eventFuncs) {
452
+ for (const func of funcs) {
453
+ app.once(event, () => func(app));
454
+ }
428
455
  }
429
456
  }
430
457
  /**
@@ -438,7 +465,7 @@ class Loader {
438
465
  static LoadConfigs(app, loadPath) {
439
466
  const frameConfig = {};
440
467
  // Logger.Debug(`Load configuration path: ${app.thinkPath}/config`);
441
- koatty_loader.Load(["./config"], app.thinkPath, function (name, path, exp) {
468
+ koatty_loader.Load(["./config"], app.koattyPath, function (name, path, exp) {
442
469
  frameConfig[name] = exp;
443
470
  });
444
471
  if (koatty_lib.Helper.isArray(loadPath)) {
@@ -462,7 +489,7 @@ class Loader {
462
489
  middlewareConf = { config: {}, list: [] };
463
490
  }
464
491
  //Mount default middleware
465
- koatty_loader.Load(loadPath || ["./middleware"], app.thinkPath);
492
+ koatty_loader.Load(loadPath || ["./middleware"], app.koattyPath);
466
493
  //Mount application middleware
467
494
  // const middleware: any = {};
468
495
  const appMiddleware = koatty_container.IOCContainer.listClass("MIDDLEWARE") ?? [];
@@ -602,8 +629,12 @@ class Loader {
602
629
  const pluginConfList = pluginsConf.list;
603
630
  for (const key of pluginConfList) {
604
631
  const handle = koatty_container.IOCContainer.get(key, "COMPONENT");
632
+ if (!handle) {
633
+ Logger.Error(`Plugin ${key} load error.`);
634
+ continue;
635
+ }
605
636
  if (!koatty_lib.Helper.isFunction(handle.run)) {
606
- Logger.Error(`plugin ${key} must be implements method 'run'.`);
637
+ Logger.Error(`Plugin ${key} must be implements method 'run'.`);
607
638
  continue;
608
639
  }
609
640
  if (pluginsConf.config[key] === false) {
@@ -616,7 +647,7 @@ class Loader {
616
647
  }
617
648
  }
618
649
 
619
- var version = "3.9.5";
650
+ var version = "3.10.0";
620
651
  var engines = {
621
652
  node: ">12.0.0"
622
653
  };
@@ -713,10 +744,10 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
713
744
  // configuration metadata
714
745
  const configurationMetas = Loader.GetConfigurationMetas(app, target);
715
746
  Loader.LoadConfigs(app, configurationMetas);
716
- // Load App ready hooks
717
- Loader.LoadAppBootHooks(app, target);
718
- // app.emit("appBoot");
719
- await asyncEvent(app, 'appBoot');
747
+ // Load App event hooks
748
+ Loader.LoadAppEventHooks(app, target);
749
+ Logger.Log('Koatty', '', 'Emit App Boot ...');
750
+ await asyncEvent(app, "appBoot" /* AppEvent.appBoot */);
720
751
  // Load Plugin
721
752
  Logger.Log('Koatty', '', 'Load Plugins ...');
722
753
  await Loader.LoadPlugins(app);
@@ -740,7 +771,7 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
740
771
  koatty_lib.Helper.define(app, "router", koatty_serve.NewRouter(app));
741
772
  // Emit app ready event
742
773
  Logger.Log('Koatty', '', 'Emit App Ready ...');
743
- await asyncEvent(app, 'appReady');
774
+ await asyncEvent(app, "appReady" /* AppEvent.appReady */);
744
775
  // Load Routers
745
776
  Logger.Log('Koatty', '', 'Load Routers ...');
746
777
  app.router.LoadRouter(controllers);
@@ -857,23 +888,23 @@ function ConfigurationScan(scanPath) {
857
888
  };
858
889
  }
859
890
  /**
860
- * bind AppBootHookFunc
891
+ * @description: bind App event hook func
861
892
  * example:
862
893
  * export function TestDecorator(): ClassDecorator {
863
894
  * return (target: any) => {
864
- * BindAppBootHook((app: Koatty) => {
895
+ * BindEventHook(AppEvent.appBoot, (app: Koatty) => {
865
896
  * // todo
866
897
  * return Promise.resolve();
867
898
  * }, target)
868
899
  * }
869
900
  * }
870
- *
871
- * @export
872
- * @param {AppBootHookFunc} func
873
- * @param {*} target
901
+ * @param {AppEvent} eventName
902
+ * @param {EventHookFunc} eventFunc
903
+ * @param {any} target
904
+ * @return {*}
874
905
  */
875
- function BindAppBootHook(func, target) {
876
- koatty_container.IOCContainer.attachClassMetadata(koatty_container.TAGGED_CLS, APP_BOOT_HOOK, func, target);
906
+ function BindEventHook(eventName, eventFunc, target) {
907
+ koatty_container.IOCContainer.attachClassMetadata(koatty_container.TAGGED_CLS, eventName, eventFunc, target);
877
908
  }
878
909
 
879
910
  /**
@@ -993,7 +1024,7 @@ Object.defineProperty(exports, 'Helper', {
993
1024
  });
994
1025
  exports.BaseController = BaseController;
995
1026
  exports.BaseService = BaseService;
996
- exports.BindAppBootHook = BindAppBootHook;
1027
+ exports.BindEventHook = BindEventHook;
997
1028
  exports.Bootstrap = Bootstrap;
998
1029
  exports.Component = Component;
999
1030
  exports.ComponentScan = ComponentScan;
package/dist/index.mjs CHANGED
@@ -1,12 +1,12 @@
1
1
  /*!
2
2
  * @Author: richen
3
- * @Date: 2023-09-12 11:22:03
3
+ * @Date: 2023-11-08 15:27:56
4
4
  * @License: BSD (3-Clause)
5
5
  * @Copyright (c) - <richenlin(at)gmail.com>
6
6
  * @HomePage: https://koatty.org/
7
7
  */
8
8
  import 'reflect-metadata';
9
- import { Koatty } from 'koatty_core';
9
+ import { AppEventArr, Koatty } from 'koatty_core';
10
10
  export * from 'koatty_core';
11
11
  import * as path from 'path';
12
12
  import { Load } from 'koatty_loader';
@@ -138,7 +138,6 @@ function formatApiData(msg, data, defaultCode) {
138
138
  */
139
139
  const COMPONENT_SCAN = 'COMPONENT_SCAN';
140
140
  const CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
141
- const APP_BOOT_HOOK = "APP_BOOT_HOOK";
142
141
  // tslint:disable: no-irregular-whitespace
143
142
  const LOGO = `
144
143
 
@@ -280,10 +279,10 @@ class Loader {
280
279
  // define path
281
280
  const rootPath = app.rootPath || process.cwd();
282
281
  const appPath = app.appPath || path.resolve(rootPath, env.indexOf('ts-node') > -1 ? 'src' : 'dist');
283
- const thinkPath = path.resolve(__dirname, '..');
282
+ const koattyPath = path.resolve(__dirname, '..');
284
283
  Helper.define(app, 'rootPath', rootPath);
285
284
  Helper.define(app, 'appPath', appPath);
286
- Helper.define(app, 'thinkPath', thinkPath);
285
+ Helper.define(app, 'koattyPath', koattyPath);
287
286
  //
288
287
  if (Helper.isEmpty(app.name)) {
289
288
  const pkg = Helper.safeRequire(`${path.dirname(appPath)}/package.json`);
@@ -294,12 +293,11 @@ class Loader {
294
293
  }
295
294
  process.env.ROOT_PATH = rootPath;
296
295
  process.env.APP_PATH = appPath;
297
- process.env.THINK_PATH = thinkPath;
296
+ process.env.KOATTY_PATH = koattyPath;
298
297
  // Compatible with old version, will be deprecated
299
298
  Helper.define(app, 'prevent', prevent);
300
- Helper.define(app, 'root_path', rootPath);
301
- Helper.define(app, 'app_path', appPath);
302
- Helper.define(app, 'think_path', thinkPath);
299
+ Helper.define(app, 'thinkPath', koattyPath);
300
+ process.env.THINK_PATH = koattyPath;
303
301
  }
304
302
  /**
305
303
  * Get component metadata
@@ -397,20 +395,49 @@ class Loader {
397
395
  }
398
396
  }
399
397
  /**
400
- * Load app ready hook funcs
398
+ * Load app event hook funcs
401
399
  *
402
400
  * @static
403
401
  * @param {Koatty} app
404
402
  * @param {*} target
405
403
  * @memberof Loader
406
404
  */
407
- static LoadAppBootHooks(app, target) {
408
- const funcs = IOCContainer.getClassMetadata(TAGGED_CLS, APP_BOOT_HOOK, target);
409
- if (Helper.isArray(funcs)) {
410
- funcs.forEach((element) => {
411
- app.once('appBoot', () => element(app));
412
- return null;
413
- });
405
+ static LoadAppEventHooks(app, target) {
406
+ const eventFuncs = new Map();
407
+ for (const event of AppEventArr) {
408
+ let funcs;
409
+ switch (event) {
410
+ case "appBoot" /* AppEvent.appBoot */:
411
+ funcs = IOCContainer.getClassMetadata(TAGGED_CLS, "appBoot" /* AppEvent.appBoot */, target);
412
+ if (Helper.isArray(funcs)) {
413
+ eventFuncs.set("appBoot" /* AppEvent.appBoot */, funcs);
414
+ }
415
+ break;
416
+ case "appReady" /* AppEvent.appReady */:
417
+ funcs = IOCContainer.getClassMetadata(TAGGED_CLS, "appReady" /* AppEvent.appReady */, target);
418
+ if (Helper.isArray(funcs)) {
419
+ eventFuncs.set("appReady" /* AppEvent.appReady */, funcs);
420
+ }
421
+ break;
422
+ case "appStart" /* AppEvent.appStart */:
423
+ funcs = IOCContainer.getClassMetadata(TAGGED_CLS, "appStart" /* AppEvent.appStart */, target);
424
+ if (Helper.isArray(funcs)) {
425
+ eventFuncs.set("appStart" /* AppEvent.appStart */, funcs);
426
+ }
427
+ break;
428
+ case "appStop" /* AppEvent.appStop */:
429
+ funcs = IOCContainer.getClassMetadata(TAGGED_CLS, "appStop" /* AppEvent.appStop */, target);
430
+ if (Helper.isArray(funcs)) {
431
+ eventFuncs.set("appStop" /* AppEvent.appStop */, funcs);
432
+ }
433
+ break;
434
+ }
435
+ }
436
+ // loop event emit
437
+ for (const [event, funcs] of eventFuncs) {
438
+ for (const func of funcs) {
439
+ app.once(event, () => func(app));
440
+ }
414
441
  }
415
442
  }
416
443
  /**
@@ -424,7 +451,7 @@ class Loader {
424
451
  static LoadConfigs(app, loadPath) {
425
452
  const frameConfig = {};
426
453
  // Logger.Debug(`Load configuration path: ${app.thinkPath}/config`);
427
- Load(["./config"], app.thinkPath, function (name, path, exp) {
454
+ Load(["./config"], app.koattyPath, function (name, path, exp) {
428
455
  frameConfig[name] = exp;
429
456
  });
430
457
  if (Helper.isArray(loadPath)) {
@@ -448,7 +475,7 @@ class Loader {
448
475
  middlewareConf = { config: {}, list: [] };
449
476
  }
450
477
  //Mount default middleware
451
- Load(loadPath || ["./middleware"], app.thinkPath);
478
+ Load(loadPath || ["./middleware"], app.koattyPath);
452
479
  //Mount application middleware
453
480
  // const middleware: any = {};
454
481
  const appMiddleware = IOCContainer.listClass("MIDDLEWARE") ?? [];
@@ -588,8 +615,12 @@ class Loader {
588
615
  const pluginConfList = pluginsConf.list;
589
616
  for (const key of pluginConfList) {
590
617
  const handle = IOCContainer.get(key, "COMPONENT");
618
+ if (!handle) {
619
+ Logger.Error(`Plugin ${key} load error.`);
620
+ continue;
621
+ }
591
622
  if (!Helper.isFunction(handle.run)) {
592
- Logger.Error(`plugin ${key} must be implements method 'run'.`);
623
+ Logger.Error(`Plugin ${key} must be implements method 'run'.`);
593
624
  continue;
594
625
  }
595
626
  if (pluginsConf.config[key] === false) {
@@ -602,7 +633,7 @@ class Loader {
602
633
  }
603
634
  }
604
635
 
605
- var version = "3.9.5";
636
+ var version = "3.10.0";
606
637
  var engines = {
607
638
  node: ">12.0.0"
608
639
  };
@@ -699,10 +730,10 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
699
730
  // configuration metadata
700
731
  const configurationMetas = Loader.GetConfigurationMetas(app, target);
701
732
  Loader.LoadConfigs(app, configurationMetas);
702
- // Load App ready hooks
703
- Loader.LoadAppBootHooks(app, target);
704
- // app.emit("appBoot");
705
- await asyncEvent(app, 'appBoot');
733
+ // Load App event hooks
734
+ Loader.LoadAppEventHooks(app, target);
735
+ Logger.Log('Koatty', '', 'Emit App Boot ...');
736
+ await asyncEvent(app, "appBoot" /* AppEvent.appBoot */);
706
737
  // Load Plugin
707
738
  Logger.Log('Koatty', '', 'Load Plugins ...');
708
739
  await Loader.LoadPlugins(app);
@@ -726,7 +757,7 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
726
757
  Helper.define(app, "router", NewRouter(app));
727
758
  // Emit app ready event
728
759
  Logger.Log('Koatty', '', 'Emit App Ready ...');
729
- await asyncEvent(app, 'appReady');
760
+ await asyncEvent(app, "appReady" /* AppEvent.appReady */);
730
761
  // Load Routers
731
762
  Logger.Log('Koatty', '', 'Load Routers ...');
732
763
  app.router.LoadRouter(controllers);
@@ -843,23 +874,23 @@ function ConfigurationScan(scanPath) {
843
874
  };
844
875
  }
845
876
  /**
846
- * bind AppBootHookFunc
877
+ * @description: bind App event hook func
847
878
  * example:
848
879
  * export function TestDecorator(): ClassDecorator {
849
880
  * return (target: any) => {
850
- * BindAppBootHook((app: Koatty) => {
881
+ * BindEventHook(AppEvent.appBoot, (app: Koatty) => {
851
882
  * // todo
852
883
  * return Promise.resolve();
853
884
  * }, target)
854
885
  * }
855
886
  * }
856
- *
857
- * @export
858
- * @param {AppBootHookFunc} func
859
- * @param {*} target
887
+ * @param {AppEvent} eventName
888
+ * @param {EventHookFunc} eventFunc
889
+ * @param {any} target
890
+ * @return {*}
860
891
  */
861
- function BindAppBootHook(func, target) {
862
- IOCContainer.attachClassMetadata(TAGGED_CLS, APP_BOOT_HOOK, func, target);
892
+ function BindEventHook(eventName, eventFunc, target) {
893
+ IOCContainer.attachClassMetadata(TAGGED_CLS, eventName, eventFunc, target);
863
894
  }
864
895
 
865
896
  /**
@@ -965,4 +996,4 @@ class BaseService {
965
996
  }
966
997
  }
967
998
 
968
- export { BaseController, BaseService, BindAppBootHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, Plugin, Service };
999
+ export { BaseController, BaseService, BindEventHook, Bootstrap, Component, ComponentScan, ConfigurationScan, Controller, ExecBootStrap, Logger, Middleware, Plugin, Service };
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.9.5",
3
+ "version": "3.10.0",
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",
@@ -81,7 +81,7 @@
81
81
  "koa": "^2.14.2",
82
82
  "koatty_config": "^1.1.6",
83
83
  "koatty_container": "^1.8.1",
84
- "koatty_core": "^1.7.10",
84
+ "koatty_core": "^1.8.1",
85
85
  "koatty_exception": "^1.2.8",
86
86
  "koatty_lib": "^1.3.4",
87
87
  "koatty_loader": "^1.1.0",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koatty",
3
- "version": "3.9.5",
3
+ "version": "3.10.0",
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",
@@ -81,7 +81,7 @@
81
81
  "koa": "^2.14.2",
82
82
  "koatty_config": "^1.1.6",
83
83
  "koatty_container": "^1.8.1",
84
- "koatty_core": "^1.7.10",
84
+ "koatty_core": "^1.8.1",
85
85
  "koatty_exception": "^1.2.8",
86
86
  "koatty_lib": "^1.3.4",
87
87
  "koatty_loader": "^1.1.0",