koatty 3.8.0-5 → 3.8.0-6
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 +8 -0
- package/dist/index.d.ts +5 -5
- package/dist/index.js +39 -41
- package/dist/index.mjs +39 -41
- package/dist/package.json +2 -2
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
@@ -2,6 +2,14 @@
|
|
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.8.0-6](https://github.com/thinkkoa/koatty/compare/v3.8.0-5...v3.8.0-6) (2023-03-04)
|
6
|
+
|
7
|
+
|
8
|
+
### Bug Fixes
|
9
|
+
|
10
|
+
* change event ([7d651a7](https://github.com/thinkkoa/koatty/commit/7d651a7b3453c0878dd37d0890509b2908e4afdf))
|
11
|
+
* 修改listen callback函数类型 ([9a3b29f](https://github.com/thinkkoa/koatty/commit/9a3b29f8d16a06b3627e5ccf88c08460e2cc3ae2))
|
12
|
+
|
5
13
|
## [3.8.0-5](https://github.com/thinkkoa/koatty/compare/v3.8.0-4...v3.8.0-5) (2023-02-26)
|
6
14
|
|
7
15
|
## [3.8.0-4](https://github.com/thinkkoa/koatty/compare/v3.8.0-3...v3.8.0-4) (2023-02-26)
|
package/dist/index.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2023-
|
3
|
+
* @Date: 2023-03-05 01:16:27
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -31,7 +31,7 @@ export declare interface ApiOutput {
|
|
31
31
|
data: any;
|
32
32
|
}
|
33
33
|
|
34
|
-
export declare type
|
34
|
+
export declare type AppBootHookFunc = (app: Koatty) => Promise<any>;
|
35
35
|
|
36
36
|
/**
|
37
37
|
* Base controller
|
@@ -104,7 +104,7 @@ export declare class BaseService implements IService {
|
|
104
104
|
* example:
|
105
105
|
* export function TestDecorator(): ClassDecorator {
|
106
106
|
* return (target: any) => {
|
107
|
-
*
|
107
|
+
* BindAppBootHook((app: Koatty) => {
|
108
108
|
* // todo
|
109
109
|
* return Promise.resolve();
|
110
110
|
* }, target)
|
@@ -112,10 +112,10 @@ export declare class BaseService implements IService {
|
|
112
112
|
* }
|
113
113
|
*
|
114
114
|
* @export
|
115
|
-
* @param {
|
115
|
+
* @param {AppBootHookFunc} func
|
116
116
|
* @param {*} target
|
117
117
|
*/
|
118
|
-
export declare function
|
118
|
+
export declare function BindAppBootHook(func: AppBootHookFunc, 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-
|
3
|
+
* @Date: 2023-03-05 01:16:11
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -152,7 +152,7 @@ function formatApiData(msg, data, defaultCode) {
|
|
152
152
|
*/
|
153
153
|
const COMPONENT_SCAN = 'COMPONENT_SCAN';
|
154
154
|
const CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
|
155
|
-
const
|
155
|
+
const APP_BOOT_HOOK = "APP_BOOT_HOOK";
|
156
156
|
// tslint:disable: no-irregular-whitespace
|
157
157
|
const LOGO = `
|
158
158
|
|
@@ -418,11 +418,11 @@ class Loader {
|
|
418
418
|
* @param {*} target
|
419
419
|
* @memberof Loader
|
420
420
|
*/
|
421
|
-
static
|
422
|
-
const funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS,
|
421
|
+
static LoadAppBootHooks(app, target) {
|
422
|
+
const funcs = koatty_container.IOCContainer.getClassMetadata(koatty_container.TAGGED_CLS, APP_BOOT_HOOK, target);
|
423
423
|
if (koatty_lib.Helper.isArray(funcs)) {
|
424
424
|
funcs.forEach((element) => {
|
425
|
-
app.once('
|
425
|
+
app.once('appBoot', () => element(app));
|
426
426
|
return null;
|
427
427
|
});
|
428
428
|
}
|
@@ -616,7 +616,7 @@ class Loader {
|
|
616
616
|
}
|
617
617
|
}
|
618
618
|
|
619
|
-
var version = "3.8.0-
|
619
|
+
var version = "3.8.0-6";
|
620
620
|
var engines = {
|
621
621
|
node: ">12.0.0"
|
622
622
|
};
|
@@ -713,13 +713,13 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
|
|
713
713
|
// configuration metadata
|
714
714
|
const configurationMetas = Loader.GetConfigurationMetas(app, target);
|
715
715
|
Loader.LoadConfigs(app, configurationMetas);
|
716
|
+
// Load App ready hooks
|
717
|
+
Loader.LoadAppBootHooks(app, target);
|
718
|
+
// app.emit("appBoot");
|
719
|
+
await asyncEvent(app, 'appBoot');
|
716
720
|
// Load Plugin
|
717
721
|
Logger.Log('Koatty', '', 'Load Plugins ...');
|
718
722
|
await Loader.LoadPlugins(app);
|
719
|
-
// app.emit("appBoot");
|
720
|
-
await asyncEvent(app, 'appBoot');
|
721
|
-
// Load App ready hooks
|
722
|
-
Loader.LoadAppReadyHooks(app, target);
|
723
723
|
// Load Middleware
|
724
724
|
Logger.Log('Koatty', '', 'Load Middlewares ...');
|
725
725
|
await Loader.LoadMiddlewares(app);
|
@@ -733,17 +733,20 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
|
|
733
733
|
Logger.Log('Koatty', '', 'Load Controllers ...');
|
734
734
|
const controllers = Loader.LoadControllers(app);
|
735
735
|
// Create Server
|
736
|
-
app.server = newServe(app);
|
736
|
+
// app.server = newServe(app);
|
737
|
+
koatty_lib.Helper.define(app, "server", newServe(app));
|
737
738
|
// Create router
|
738
|
-
app.router = newRouter(app);
|
739
|
-
|
740
|
-
Logger.Log('Koatty', '', 'Load Routers ...');
|
741
|
-
app.router.LoadRouter(controllers);
|
739
|
+
// app.router = newRouter(app);
|
740
|
+
koatty_lib.Helper.define(app, "router", newRouter(app));
|
742
741
|
// Emit app ready event
|
743
742
|
Logger.Log('Koatty', '', 'Emit App Ready ...');
|
744
743
|
await asyncEvent(app, 'appReady');
|
744
|
+
// Load Routers
|
745
|
+
Logger.Log('Koatty', '', 'Load Routers ...');
|
746
|
+
app.router.LoadRouter(controllers);
|
745
747
|
if (!isUTRuntime) {
|
746
|
-
|
748
|
+
// Start Server
|
749
|
+
app.listen(listenCallback);
|
747
750
|
}
|
748
751
|
return app;
|
749
752
|
}
|
@@ -772,26 +775,21 @@ const newRouter = function (app) {
|
|
772
775
|
* @returns {*}
|
773
776
|
*/
|
774
777
|
const listenCallback = (app) => {
|
775
|
-
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
// tslint:disable-next-line: no-unused-expression
|
791
|
-
app.appDebug && Logger.Warn(`Running in debug mode.`);
|
792
|
-
// Set Logger
|
793
|
-
Loader.SetLogger(app);
|
794
|
-
};
|
778
|
+
const options = app.server.options;
|
779
|
+
Logger.Log('Koatty', '', '====================================');
|
780
|
+
Logger.Log("Koatty", "", `Nodejs Version: ${process.version}`);
|
781
|
+
Logger.Log("Koatty", "", `Koatty Version: v${KOATTY_VERSION}`);
|
782
|
+
Logger.Log("Koatty", "", `App Environment: ${app.env}`);
|
783
|
+
Logger.Log('Koatty', '', `Server Protocol: ${(options.protocol).toUpperCase()}`);
|
784
|
+
Logger.Log("Koatty", "", `Server running at ${options.protocol === "http2" ? "https" : options.protocol}://${options.hostname || '127.0.0.1'}:${options.port}/`);
|
785
|
+
Logger.Log("Koatty", "", "====================================");
|
786
|
+
// binding event "appStop"
|
787
|
+
Logger.Log('Koatty', '', 'Bind App Stop event ...');
|
788
|
+
koatty_serve.BindProcessEvent(app, 'appStop');
|
789
|
+
// tslint:disable-next-line: no-unused-expression
|
790
|
+
app.appDebug && Logger.Warn(`Running in debug mode.`);
|
791
|
+
// Set Logger
|
792
|
+
Loader.SetLogger(app);
|
795
793
|
};
|
796
794
|
/**
|
797
795
|
* create serve
|
@@ -913,7 +911,7 @@ function ConfigurationScan(scanPath) {
|
|
913
911
|
* example:
|
914
912
|
* export function TestDecorator(): ClassDecorator {
|
915
913
|
* return (target: any) => {
|
916
|
-
*
|
914
|
+
* BindAppBootHook((app: Koatty) => {
|
917
915
|
* // todo
|
918
916
|
* return Promise.resolve();
|
919
917
|
* }, target)
|
@@ -921,11 +919,11 @@ function ConfigurationScan(scanPath) {
|
|
921
919
|
* }
|
922
920
|
*
|
923
921
|
* @export
|
924
|
-
* @param {
|
922
|
+
* @param {AppBootHookFunc} func
|
925
923
|
* @param {*} target
|
926
924
|
*/
|
927
|
-
function
|
928
|
-
koatty_container.IOCContainer.attachClassMetadata(koatty_container.TAGGED_CLS,
|
925
|
+
function BindAppBootHook(func, target) {
|
926
|
+
koatty_container.IOCContainer.attachClassMetadata(koatty_container.TAGGED_CLS, APP_BOOT_HOOK, func, target);
|
929
927
|
}
|
930
928
|
|
931
929
|
/**
|
@@ -1045,7 +1043,7 @@ Object.defineProperty(exports, 'Helper', {
|
|
1045
1043
|
});
|
1046
1044
|
exports.BaseController = BaseController;
|
1047
1045
|
exports.BaseService = BaseService;
|
1048
|
-
exports.
|
1046
|
+
exports.BindAppBootHook = BindAppBootHook;
|
1049
1047
|
exports.Bootstrap = Bootstrap;
|
1050
1048
|
exports.Component = Component;
|
1051
1049
|
exports.ComponentScan = ComponentScan;
|
package/dist/index.mjs
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
/*!
|
2
2
|
* @Author: richen
|
3
|
-
* @Date: 2023-
|
3
|
+
* @Date: 2023-03-05 01:16:11
|
4
4
|
* @License: BSD (3-Clause)
|
5
5
|
* @Copyright (c) - <richenlin(at)gmail.com>
|
6
6
|
* @HomePage: https://koatty.org/
|
@@ -138,7 +138,7 @@ function formatApiData(msg, data, defaultCode) {
|
|
138
138
|
*/
|
139
139
|
const COMPONENT_SCAN = 'COMPONENT_SCAN';
|
140
140
|
const CONFIGURATION_SCAN = 'CONFIGURATION_SCAN';
|
141
|
-
const
|
141
|
+
const APP_BOOT_HOOK = "APP_BOOT_HOOK";
|
142
142
|
// tslint:disable: no-irregular-whitespace
|
143
143
|
const LOGO = `
|
144
144
|
|
@@ -404,11 +404,11 @@ class Loader {
|
|
404
404
|
* @param {*} target
|
405
405
|
* @memberof Loader
|
406
406
|
*/
|
407
|
-
static
|
408
|
-
const funcs = IOCContainer.getClassMetadata(TAGGED_CLS,
|
407
|
+
static LoadAppBootHooks(app, target) {
|
408
|
+
const funcs = IOCContainer.getClassMetadata(TAGGED_CLS, APP_BOOT_HOOK, target);
|
409
409
|
if (Helper.isArray(funcs)) {
|
410
410
|
funcs.forEach((element) => {
|
411
|
-
app.once('
|
411
|
+
app.once('appBoot', () => element(app));
|
412
412
|
return null;
|
413
413
|
});
|
414
414
|
}
|
@@ -602,7 +602,7 @@ class Loader {
|
|
602
602
|
}
|
603
603
|
}
|
604
604
|
|
605
|
-
var version = "3.8.0-
|
605
|
+
var version = "3.8.0-6";
|
606
606
|
var engines = {
|
607
607
|
node: ">12.0.0"
|
608
608
|
};
|
@@ -699,13 +699,13 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
|
|
699
699
|
// configuration metadata
|
700
700
|
const configurationMetas = Loader.GetConfigurationMetas(app, target);
|
701
701
|
Loader.LoadConfigs(app, configurationMetas);
|
702
|
+
// Load App ready hooks
|
703
|
+
Loader.LoadAppBootHooks(app, target);
|
704
|
+
// app.emit("appBoot");
|
705
|
+
await asyncEvent(app, 'appBoot');
|
702
706
|
// Load Plugin
|
703
707
|
Logger.Log('Koatty', '', 'Load Plugins ...');
|
704
708
|
await Loader.LoadPlugins(app);
|
705
|
-
// app.emit("appBoot");
|
706
|
-
await asyncEvent(app, 'appBoot');
|
707
|
-
// Load App ready hooks
|
708
|
-
Loader.LoadAppReadyHooks(app, target);
|
709
709
|
// Load Middleware
|
710
710
|
Logger.Log('Koatty', '', 'Load Middlewares ...');
|
711
711
|
await Loader.LoadMiddlewares(app);
|
@@ -719,17 +719,20 @@ const executeBootstrap = async function (target, bootFunc, isInitiative = false)
|
|
719
719
|
Logger.Log('Koatty', '', 'Load Controllers ...');
|
720
720
|
const controllers = Loader.LoadControllers(app);
|
721
721
|
// Create Server
|
722
|
-
app.server = newServe(app);
|
722
|
+
// app.server = newServe(app);
|
723
|
+
Helper.define(app, "server", newServe(app));
|
723
724
|
// Create router
|
724
|
-
app.router = newRouter(app);
|
725
|
-
|
726
|
-
Logger.Log('Koatty', '', 'Load Routers ...');
|
727
|
-
app.router.LoadRouter(controllers);
|
725
|
+
// app.router = newRouter(app);
|
726
|
+
Helper.define(app, "router", newRouter(app));
|
728
727
|
// Emit app ready event
|
729
728
|
Logger.Log('Koatty', '', 'Emit App Ready ...');
|
730
729
|
await asyncEvent(app, 'appReady');
|
730
|
+
// Load Routers
|
731
|
+
Logger.Log('Koatty', '', 'Load Routers ...');
|
732
|
+
app.router.LoadRouter(controllers);
|
731
733
|
if (!isUTRuntime) {
|
732
|
-
|
734
|
+
// Start Server
|
735
|
+
app.listen(listenCallback);
|
733
736
|
}
|
734
737
|
return app;
|
735
738
|
}
|
@@ -758,26 +761,21 @@ const newRouter = function (app) {
|
|
758
761
|
* @returns {*}
|
759
762
|
*/
|
760
763
|
const listenCallback = (app) => {
|
761
|
-
|
762
|
-
|
763
|
-
|
764
|
-
|
765
|
-
|
766
|
-
|
767
|
-
|
768
|
-
|
769
|
-
|
770
|
-
|
771
|
-
|
772
|
-
|
773
|
-
|
774
|
-
|
775
|
-
|
776
|
-
// tslint:disable-next-line: no-unused-expression
|
777
|
-
app.appDebug && Logger.Warn(`Running in debug mode.`);
|
778
|
-
// Set Logger
|
779
|
-
Loader.SetLogger(app);
|
780
|
-
};
|
764
|
+
const options = app.server.options;
|
765
|
+
Logger.Log('Koatty', '', '====================================');
|
766
|
+
Logger.Log("Koatty", "", `Nodejs Version: ${process.version}`);
|
767
|
+
Logger.Log("Koatty", "", `Koatty Version: v${KOATTY_VERSION}`);
|
768
|
+
Logger.Log("Koatty", "", `App Environment: ${app.env}`);
|
769
|
+
Logger.Log('Koatty', '', `Server Protocol: ${(options.protocol).toUpperCase()}`);
|
770
|
+
Logger.Log("Koatty", "", `Server running at ${options.protocol === "http2" ? "https" : options.protocol}://${options.hostname || '127.0.0.1'}:${options.port}/`);
|
771
|
+
Logger.Log("Koatty", "", "====================================");
|
772
|
+
// binding event "appStop"
|
773
|
+
Logger.Log('Koatty', '', 'Bind App Stop event ...');
|
774
|
+
BindProcessEvent(app, 'appStop');
|
775
|
+
// tslint:disable-next-line: no-unused-expression
|
776
|
+
app.appDebug && Logger.Warn(`Running in debug mode.`);
|
777
|
+
// Set Logger
|
778
|
+
Loader.SetLogger(app);
|
781
779
|
};
|
782
780
|
/**
|
783
781
|
* create serve
|
@@ -899,7 +897,7 @@ function ConfigurationScan(scanPath) {
|
|
899
897
|
* example:
|
900
898
|
* export function TestDecorator(): ClassDecorator {
|
901
899
|
* return (target: any) => {
|
902
|
-
*
|
900
|
+
* BindAppBootHook((app: Koatty) => {
|
903
901
|
* // todo
|
904
902
|
* return Promise.resolve();
|
905
903
|
* }, target)
|
@@ -907,11 +905,11 @@ function ConfigurationScan(scanPath) {
|
|
907
905
|
* }
|
908
906
|
*
|
909
907
|
* @export
|
910
|
-
* @param {
|
908
|
+
* @param {AppBootHookFunc} func
|
911
909
|
* @param {*} target
|
912
910
|
*/
|
913
|
-
function
|
914
|
-
IOCContainer.attachClassMetadata(TAGGED_CLS,
|
911
|
+
function BindAppBootHook(func, target) {
|
912
|
+
IOCContainer.attachClassMetadata(TAGGED_CLS, APP_BOOT_HOOK, func, target);
|
915
913
|
}
|
916
914
|
|
917
915
|
/**
|
@@ -1017,4 +1015,4 @@ class BaseService {
|
|
1017
1015
|
}
|
1018
1016
|
}
|
1019
1017
|
|
1020
|
-
export { BaseController, BaseService,
|
1018
|
+
export { BaseController, BaseService, BindAppBootHook, 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.8.0-
|
3
|
+
"version": "3.8.0-6",
|
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",
|
@@ -82,7 +82,7 @@
|
|
82
82
|
"koa": "^2.14.1",
|
83
83
|
"koatty_config": "^1.1.6",
|
84
84
|
"koatty_container": "^1.8.0",
|
85
|
-
"koatty_core": "^1.7.
|
85
|
+
"koatty_core": "^1.7.8",
|
86
86
|
"koatty_exception": "^1.2.8",
|
87
87
|
"koatty_lib": "^1.3.2",
|
88
88
|
"koatty_loader": "^1.1.0",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "koatty",
|
3
|
-
"version": "3.8.0-
|
3
|
+
"version": "3.8.0-6",
|
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",
|
@@ -82,7 +82,7 @@
|
|
82
82
|
"koa": "^2.14.1",
|
83
83
|
"koatty_config": "^1.1.6",
|
84
84
|
"koatty_container": "^1.8.0",
|
85
|
-
"koatty_core": "^1.7.
|
85
|
+
"koatty_core": "^1.7.8",
|
86
86
|
"koatty_exception": "^1.2.8",
|
87
87
|
"koatty_lib": "^1.3.2",
|
88
88
|
"koatty_loader": "^1.1.0",
|