typespeed 2.1.3 → 2.2.1
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/dist/core.decorator.js
CHANGED
|
@@ -11,18 +11,18 @@ let globalConfig = {};
|
|
|
11
11
|
const resourceObjects = new Map();
|
|
12
12
|
const beanMapper = new Map();
|
|
13
13
|
const objectMapper = new Map();
|
|
14
|
-
const coreDir = __dirname;
|
|
15
|
-
const mainPath = path.dirname(process.argv[1]);
|
|
16
|
-
const configFile = mainPath + "/config.json";
|
|
17
|
-
if (fs.existsSync(configFile)) {
|
|
18
|
-
globalConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
19
|
-
const nodeEnv = process.env.NODE_ENV || "development";
|
|
20
|
-
const envConfigFile = mainPath + "/config-" + nodeEnv + ".json";
|
|
21
|
-
if (fs.existsSync(envConfigFile)) {
|
|
22
|
-
globalConfig = Object.assign(globalConfig, JSON.parse(fs.readFileSync(envConfigFile, "utf-8")));
|
|
23
|
-
}
|
|
24
|
-
}
|
|
25
14
|
function app(constructor) {
|
|
15
|
+
const coreDir = __dirname;
|
|
16
|
+
const mainPath = path.dirname(getRootPath() || process.argv[1]);
|
|
17
|
+
const configFile = mainPath + "/config.json";
|
|
18
|
+
if (fs.existsSync(configFile)) {
|
|
19
|
+
globalConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
20
|
+
const nodeEnv = process.env.NODE_ENV || "development";
|
|
21
|
+
const envConfigFile = mainPath + "/config-" + nodeEnv + ".json";
|
|
22
|
+
if (fs.existsSync(envConfigFile)) {
|
|
23
|
+
globalConfig = Object.assign(globalConfig, JSON.parse(fs.readFileSync(envConfigFile, "utf-8")));
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
26
|
const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
|
|
27
27
|
const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
|
|
28
28
|
(async function () {
|
|
@@ -147,6 +147,23 @@ function error(message, ...optionalParams) {
|
|
|
147
147
|
}
|
|
148
148
|
}
|
|
149
149
|
exports.error = error;
|
|
150
|
+
function getRootPath() {
|
|
151
|
+
const lines = new Error().stack.split("\n");
|
|
152
|
+
let rootPath = "";
|
|
153
|
+
let lastLine = "";
|
|
154
|
+
for (let line of lines) {
|
|
155
|
+
if (line.includes("at ") &&
|
|
156
|
+
line.includes("node:internal/modules/cjs/loader") &&
|
|
157
|
+
line.includes("Module._compile") &&
|
|
158
|
+
lastLine.includes("at ") &&
|
|
159
|
+
lastLine.includes("Object.<anonymous>")) {
|
|
160
|
+
rootPath = lastLine.split("(")[1].split(":")[0];
|
|
161
|
+
break;
|
|
162
|
+
}
|
|
163
|
+
lastLine = line;
|
|
164
|
+
}
|
|
165
|
+
return rootPath;
|
|
166
|
+
}
|
|
150
167
|
function schedule(cronTime) {
|
|
151
168
|
return (target, propertyKey) => {
|
|
152
169
|
new cron.CronJob(cronTime, target[propertyKey]).start();
|
|
@@ -37,7 +37,7 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
37
37
|
this.app.use(middleware);
|
|
38
38
|
});
|
|
39
39
|
this.setDefaultMiddleware();
|
|
40
|
-
this.app.listen(port, () => {
|
|
40
|
+
return this.app.listen(port, () => {
|
|
41
41
|
(0, core_decorator_1.log)("server start at port: " + port);
|
|
42
42
|
});
|
|
43
43
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "typespeed",
|
|
3
|
-
"version": "2.1
|
|
3
|
+
"version": "2.2.1",
|
|
4
4
|
"description": "A new Framework for TypeScript.",
|
|
5
5
|
"author": "speedphp",
|
|
6
6
|
"license": "MIT License",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"tracer": "^1.1.6",
|
|
53
53
|
"typescript": "^4.7.4",
|
|
54
54
|
"walk-sync": "^3.0.0",
|
|
55
|
-
"amqplib": "0.10.3"
|
|
56
|
-
"swagger-ui-express": "4.6.3"
|
|
55
|
+
"amqplib": "0.10.3"
|
|
57
56
|
}
|
|
58
57
|
}
|
package/src/core.decorator.ts
CHANGED
|
@@ -9,20 +9,20 @@ let globalConfig = {};
|
|
|
9
9
|
const resourceObjects = new Map<string, object>();
|
|
10
10
|
const beanMapper: Map<string, any> = new Map<string, any>();
|
|
11
11
|
const objectMapper: Map<string, any> = new Map<string, any>();
|
|
12
|
-
const coreDir = __dirname;
|
|
13
|
-
const mainPath = path.dirname(process.argv[1]);
|
|
14
|
-
|
|
15
|
-
const configFile = mainPath + "/config.json";
|
|
16
|
-
if (fs.existsSync(configFile)) {
|
|
17
|
-
globalConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
18
|
-
const nodeEnv = process.env.NODE_ENV || "development";
|
|
19
|
-
const envConfigFile = mainPath + "/config-" + nodeEnv + ".json";
|
|
20
|
-
if (fs.existsSync(envConfigFile)) {
|
|
21
|
-
globalConfig = Object.assign(globalConfig, JSON.parse(fs.readFileSync(envConfigFile, "utf-8")));
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
12
|
|
|
25
13
|
function app<T extends { new(...args: any[]): {} }>(constructor: T) {
|
|
14
|
+
const coreDir = __dirname;
|
|
15
|
+
const mainPath = path.dirname(getRootPath() || process.argv[1]);
|
|
16
|
+
const configFile = mainPath + "/config.json";
|
|
17
|
+
if (fs.existsSync(configFile)) {
|
|
18
|
+
globalConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
19
|
+
const nodeEnv = process.env.NODE_ENV || "development";
|
|
20
|
+
const envConfigFile = mainPath + "/config-" + nodeEnv + ".json";
|
|
21
|
+
if (fs.existsSync(envConfigFile)) {
|
|
22
|
+
globalConfig = Object.assign(globalConfig, JSON.parse(fs.readFileSync(envConfigFile, "utf-8")));
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
|
|
26
26
|
const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
|
|
27
27
|
const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
|
|
28
28
|
|
|
@@ -145,6 +145,23 @@ function error(message?: any, ...optionalParams: any[]) {
|
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
function getRootPath() {
|
|
149
|
+
const lines = new Error().stack.split("\n");
|
|
150
|
+
let rootPath = "";
|
|
151
|
+
let lastLine = "";
|
|
152
|
+
for (let line of lines) {
|
|
153
|
+
if (line.includes("at ") &&
|
|
154
|
+
line.includes("node:internal/modules/cjs/loader") &&
|
|
155
|
+
line.includes("Module._compile") &&
|
|
156
|
+
lastLine.includes("at ") &&
|
|
157
|
+
lastLine.includes("Object.<anonymous>")) {
|
|
158
|
+
rootPath = lastLine.split("(")[1].split(":")[0];
|
|
159
|
+
break;
|
|
160
|
+
}
|
|
161
|
+
lastLine = line;
|
|
162
|
+
}
|
|
163
|
+
return rootPath;
|
|
164
|
+
}
|
|
148
165
|
|
|
149
166
|
function schedule(cronTime: string | Date) {
|
|
150
167
|
return (target: any, propertyKey: string) => {
|
|
@@ -52,7 +52,7 @@ export default class ExpressServer extends ServerFactory {
|
|
|
52
52
|
this.middlewareList.push(middleware);
|
|
53
53
|
}
|
|
54
54
|
|
|
55
|
-
public start(port: number) {
|
|
55
|
+
public start(port: number): any {
|
|
56
56
|
this.app.use(this.authentication.afterCompletion);
|
|
57
57
|
this.middlewareList.forEach(middleware => {
|
|
58
58
|
this.app.use(middleware);
|
|
@@ -60,7 +60,7 @@ export default class ExpressServer extends ServerFactory {
|
|
|
60
60
|
|
|
61
61
|
this.setDefaultMiddleware();
|
|
62
62
|
|
|
63
|
-
this.app.listen(port, () => {
|
|
63
|
+
return this.app.listen(port, () => {
|
|
64
64
|
log("server start at port: " + port);
|
|
65
65
|
});
|
|
66
66
|
}
|