koatty 3.6.7 → 3.6.8
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/.rollup.config.js +63 -0
- package/.vscode/launch.json +17 -1
- package/CHANGELOG.md +10 -0
- package/README.md +10 -6
- package/dist/README.md +10 -6
- package/dist/index.d.ts +3 -3
- package/dist/index.js +96 -83
- package/dist/index.mjs +57 -44
- package/dist/package.json +94 -95
- package/package.json +94 -95
- package/tsconfig.test.json +15 -0
- package/.vscode/settings.json +0 -3
- package/jest-html-reporters-attach/index.js +0 -58
- package/jest-html-reporters-attach/result.js +0 -1
@@ -0,0 +1,63 @@
|
|
1
|
+
/*
|
2
|
+
* @Description:
|
3
|
+
* @Usage:
|
4
|
+
* @Author: richen
|
5
|
+
* @Date: 2021-12-17 10:20:44
|
6
|
+
* @LastEditTime: 2022-05-27 11:50:23
|
7
|
+
*/
|
8
|
+
import json from "@rollup/plugin-json";
|
9
|
+
import typescript from 'rollup-plugin-typescript2';
|
10
|
+
// import babel from '@rollup/plugin-babel';
|
11
|
+
|
12
|
+
export default [
|
13
|
+
{
|
14
|
+
input: './src/index.ts',
|
15
|
+
output: [{
|
16
|
+
format: 'cjs',
|
17
|
+
file: './dist/index.js',
|
18
|
+
banner: require('./scripts/copyright')
|
19
|
+
}],
|
20
|
+
plugins: [
|
21
|
+
// babel({
|
22
|
+
// babelHelpers: "runtime",
|
23
|
+
// configFile: './babel.config.js',
|
24
|
+
// exclude: 'node_modules/**',
|
25
|
+
// }),
|
26
|
+
json(),
|
27
|
+
typescript({
|
28
|
+
tsconfigOverride: {
|
29
|
+
compilerOptions: {
|
30
|
+
declaration: false,
|
31
|
+
declarationMap: false,
|
32
|
+
module: "ESNext"
|
33
|
+
}
|
34
|
+
}
|
35
|
+
})
|
36
|
+
]
|
37
|
+
},
|
38
|
+
{
|
39
|
+
input: './src/index.ts',
|
40
|
+
output: [{
|
41
|
+
format: 'es',
|
42
|
+
file: './dist/index.mjs',
|
43
|
+
banner: require('./scripts/copyright')
|
44
|
+
}],
|
45
|
+
plugins: [
|
46
|
+
// babel({
|
47
|
+
// babelHelpers: "runtime",
|
48
|
+
// configFile: './babel.config.js',
|
49
|
+
// exclude: 'node_modules/**',
|
50
|
+
// }),
|
51
|
+
json(),
|
52
|
+
typescript({
|
53
|
+
tsconfigOverride: {
|
54
|
+
compilerOptions: {
|
55
|
+
declaration: false,
|
56
|
+
declarationMap: false,
|
57
|
+
module: "ESNext"
|
58
|
+
}
|
59
|
+
}
|
60
|
+
})
|
61
|
+
]
|
62
|
+
}
|
63
|
+
]
|
package/.vscode/launch.json
CHANGED
@@ -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](https://github.com/thinkkoa/koatty/compare/v3.6.8-2...v3.6.8) (2022-05-27)
|
6
|
+
|
7
|
+
### [3.6.8-2](https://github.com/thinkkoa/koatty/compare/v3.6.8-1...v3.6.8-2) (2022-03-15)
|
8
|
+
|
9
|
+
### [3.6.8-1](https://github.com/thinkkoa/koatty/compare/v3.6.8-0...v3.6.8-1) (2022-03-15)
|
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.8-0](https://github.com/thinkkoa/koatty/compare/v3.6.7...v3.6.8-0) (2022-03-14)
|
14
|
+
|
5
15
|
### [3.6.7](https://github.com/thinkkoa/koatty/compare/v3.6.6...v3.6.7) (2022-03-09)
|
6
16
|
|
7
17
|
### [3.6.6](https://github.com/thinkkoa/koatty/compare/v3.6.5...v3.6.6) (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.
|
114
|
+
server = await appInstance.listen();
|
115
115
|
});
|
116
116
|
|
117
|
-
|
118
|
-
|
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.
|
114
|
+
server = await appInstance.listen();
|
115
115
|
});
|
116
116
|
|
117
|
-
|
118
|
-
|
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-
|
3
|
+
* @Date: 2022-05-27 11:53:36
|
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<
|
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-
|
3
|
+
* @Date: 2022-05-27 11:53:16
|
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
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
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
|
-
|
44
|
-
|
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
|
-
|
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
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
764
|
+
controllers.push(item.id);
|
760
765
|
}
|
761
766
|
});
|
762
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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]
|
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.
|
850
|
+
var version = "3.6.8";
|
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-
|
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
|
-
|
969
|
-
|
970
|
-
|
971
|
-
|
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
|
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
|
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
|
-
|
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
|
-
|
1262
|
-
|
1274
|
+
enumerable: true,
|
1275
|
+
get: function () { return koatty_lib.Helper; }
|
1263
1276
|
});
|
1264
1277
|
Object.defineProperty(exports, 'Config', {
|
1265
|
-
|
1266
|
-
|
1278
|
+
enumerable: true,
|
1279
|
+
get: function () { return koatty_config.Config; }
|
1267
1280
|
});
|
1268
1281
|
Object.defineProperty(exports, 'Value', {
|
1269
|
-
|
1270
|
-
|
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
|
-
|
1288
|
-
|
1289
|
-
|
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
|
-
|
1294
|
-
|
1295
|
-
|
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
|
-
|
1300
|
-
|
1301
|
-
|
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
|
-
|
1306
|
-
|
1307
|
-
|
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
|
-
|
1312
|
-
|
1313
|
-
|
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
|
});
|