typespeed 2.2.1 → 2.3.2
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/app/nodemon.json +5 -0
- package/{test → app}/package.json +0 -1
- package/{test → app}/src/config-development.json +8 -1
- package/{test → app}/src/config.json +3 -4
- package/{test → app}/src/custom-log.class.ts +1 -1
- package/{test → app}/src/jwt-authentication.class.ts +3 -2
- package/{test → app}/src/main.ts +9 -2
- package/{test → app}/src/test-database.class.ts +1 -1
- package/app/src/test-log.class.ts +11 -0
- package/{test → app}/src/test-mq.class.ts +2 -6
- package/{test → app}/src/test-orm.class.ts +8 -8
- package/{test → app}/src/test-request.class.ts +4 -4
- package/{test → app}/src/user-model.class.ts +12 -11
- package/dist/core.decorator.js +1 -84
- package/dist/database.decorator.js +1 -1
- package/dist/default/express-server.class.js +10 -11
- package/dist/default/node-cache.class.js +2 -1
- package/dist/default/rabbitmq.class.js +3 -2
- package/dist/default/read-write-db.class.js +8 -7
- package/dist/default/redis.class.js +3 -2
- package/dist/factory/log-factory.class.js +0 -3
- package/dist/typespeed.js +85 -1
- package/package.json +15 -3
- package/src/core.decorator.ts +1 -85
- package/src/database.decorator.ts +1 -1
- package/src/default/express-server.class.ts +4 -5
- package/src/default/node-cache.class.ts +2 -1
- package/src/default/rabbitmq.class.ts +2 -1
- package/src/default/read-write-db.class.ts +2 -2
- package/src/default/redis.class.ts +2 -2
- package/src/factory/log-factory.class.ts +0 -3
- package/src/factory/server-factory.class.ts +1 -1
- package/src/typespeed.ts +86 -1
- package/test/database.test.ts +61 -0
- package/test/first-page.test.ts +41 -0
- package/test/hooks.ts +10 -0
- package/test/mq.test.ts +34 -0
- package/test/orm.test.ts +65 -0
- package/test/request.test.ts +50 -0
- package/test/second-page.test.ts +51 -0
- package/tsconfig.json +2 -3
- package/test/nodemon.json +0 -6
- package/test/src/test-log.class.ts +0 -9
- /package/{test → app}/node_modules/.package-lock.json +0 -0
- /package/{test → app}/node_modules/@types/body-parser/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/body-parser/README.md +0 -0
- /package/{test → app}/node_modules/@types/body-parser/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/body-parser/package.json +0 -0
- /package/{test → app}/node_modules/@types/connect/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/connect/README.md +0 -0
- /package/{test → app}/node_modules/@types/connect/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/connect/package.json +0 -0
- /package/{test → app}/node_modules/@types/express/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/express/README.md +0 -0
- /package/{test → app}/node_modules/@types/express/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/express/package.json +0 -0
- /package/{test → app}/node_modules/@types/express-serve-static-core/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/express-serve-static-core/README.md +0 -0
- /package/{test → app}/node_modules/@types/express-serve-static-core/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/express-serve-static-core/package.json +0 -0
- /package/{test → app}/node_modules/@types/mime/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/mime/Mime.d.ts +0 -0
- /package/{test → app}/node_modules/@types/mime/README.md +0 -0
- /package/{test → app}/node_modules/@types/mime/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/mime/lite.d.ts +0 -0
- /package/{test → app}/node_modules/@types/mime/package.json +0 -0
- /package/{test → app}/node_modules/@types/node/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/node/README.md +0 -0
- /package/{test → app}/node_modules/@types/node/assert/strict.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/assert.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/async_hooks.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/buffer.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/child_process.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/cluster.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/console.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/constants.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/crypto.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/dgram.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/diagnostics_channel.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/dns/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/dns.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/dom-events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/domain.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/fs/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/fs.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/globals.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/globals.global.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/http.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/http2.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/https.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/inspector.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/module.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/net.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/os.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/package.json +0 -0
- /package/{test → app}/node_modules/@types/node/path.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/perf_hooks.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/process.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/punycode.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/querystring.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/readline/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/readline.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/repl.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/stream/consumers.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/stream/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/stream/web.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/stream.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/string_decoder.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/test.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/timers/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/timers.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/tls.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/trace_events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/assert/strict.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/assert.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/async_hooks.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/buffer.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/child_process.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/cluster.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/console.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/constants.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/crypto.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/dgram.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/diagnostics_channel.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/dns/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/dns.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/dom-events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/domain.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/fs/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/fs.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/globals.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/globals.global.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/http.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/http2.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/https.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/inspector.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/module.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/net.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/os.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/path.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/perf_hooks.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/process.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/punycode.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/querystring.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/readline/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/readline.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/repl.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/stream/consumers.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/stream/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/stream/web.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/stream.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/string_decoder.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/test.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/timers/promises.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/timers.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/tls.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/trace_events.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/tty.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/url.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/util.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/v8.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/vm.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/wasi.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/worker_threads.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/ts4.8/zlib.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/tty.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/url.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/util.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/v8.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/vm.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/wasi.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/worker_threads.d.ts +0 -0
- /package/{test → app}/node_modules/@types/node/zlib.d.ts +0 -0
- /package/{test → app}/node_modules/@types/qs/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/qs/README.md +0 -0
- /package/{test → app}/node_modules/@types/qs/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/qs/package.json +0 -0
- /package/{test → app}/node_modules/@types/range-parser/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/range-parser/README.md +0 -0
- /package/{test → app}/node_modules/@types/range-parser/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/range-parser/package.json +0 -0
- /package/{test → app}/node_modules/@types/send/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/send/README.md +0 -0
- /package/{test → app}/node_modules/@types/send/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/send/package.json +0 -0
- /package/{test → app}/node_modules/@types/serve-static/LICENSE +0 -0
- /package/{test → app}/node_modules/@types/serve-static/README.md +0 -0
- /package/{test → app}/node_modules/@types/serve-static/index.d.ts +0 -0
- /package/{test → app}/node_modules/@types/serve-static/package.json +0 -0
- /package/{test → app}/node_modules/colors/LICENSE +0 -0
- /package/{test → app}/node_modules/colors/README.md +0 -0
- /package/{test → app}/node_modules/colors/examples/normal-usage.js +0 -0
- /package/{test → app}/node_modules/colors/examples/safe-string.js +0 -0
- /package/{test → app}/node_modules/colors/index.d.ts +0 -0
- /package/{test → app}/node_modules/colors/lib/colors.js +0 -0
- /package/{test → app}/node_modules/colors/lib/custom/trap.js +0 -0
- /package/{test → app}/node_modules/colors/lib/custom/zalgo.js +0 -0
- /package/{test → app}/node_modules/colors/lib/extendStringPrototype.js +0 -0
- /package/{test → app}/node_modules/colors/lib/index.js +0 -0
- /package/{test → app}/node_modules/colors/lib/maps/america.js +0 -0
- /package/{test → app}/node_modules/colors/lib/maps/rainbow.js +0 -0
- /package/{test → app}/node_modules/colors/lib/maps/random.js +0 -0
- /package/{test → app}/node_modules/colors/lib/maps/zebra.js +0 -0
- /package/{test → app}/node_modules/colors/lib/styles.js +0 -0
- /package/{test → app}/node_modules/colors/lib/system/has-flag.js +0 -0
- /package/{test → app}/node_modules/colors/lib/system/supports-colors.js +0 -0
- /package/{test → app}/node_modules/colors/package.json +0 -0
- /package/{test → app}/node_modules/colors/safe.d.ts +0 -0
- /package/{test → app}/node_modules/colors/safe.js +0 -0
- /package/{test → app}/node_modules/colors/themes/generic-logging.js +0 -0
- /package/{test → app}/node_modules/dateformat/LICENSE +0 -0
- /package/{test → app}/node_modules/dateformat/Readme.md +0 -0
- /package/{test → app}/node_modules/dateformat/lib/dateformat.js +0 -0
- /package/{test → app}/node_modules/dateformat/package.json +0 -0
- /package/{test → app}/node_modules/mkdirp/CHANGELOG.md +0 -0
- /package/{test → app}/node_modules/mkdirp/LICENSE +0 -0
- /package/{test → app}/node_modules/mkdirp/bin/cmd.js +0 -0
- /package/{test → app}/node_modules/mkdirp/index.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/find-made.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/mkdirp-manual.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/mkdirp-native.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/opts-arg.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/path-arg.js +0 -0
- /package/{test → app}/node_modules/mkdirp/lib/use-native.js +0 -0
- /package/{test → app}/node_modules/mkdirp/package.json +0 -0
- /package/{test → app}/node_modules/mkdirp/readme.markdown +0 -0
- /package/{test → app}/node_modules/tinytim/.travis.yml +0 -0
- /package/{test → app}/node_modules/tinytim/README.md +0 -0
- /package/{test → app}/node_modules/tinytim/index.js +0 -0
- /package/{test → app}/node_modules/tinytim/lib/index.js +0 -0
- /package/{test → app}/node_modules/tinytim/lib/tinytim.js +0 -0
- /package/{test → app}/node_modules/tinytim/package.json +0 -0
- /package/{test → app}/node_modules/tinytim/test/files/html.tim +0 -0
- /package/{test → app}/node_modules/tinytim/test/files/string.tim +0 -0
- /package/{test → app}/node_modules/tinytim/test/files/string2.tim +0 -0
- /package/{test → app}/node_modules/tinytim/test/render-file-replace.js +0 -0
- /package/{test → app}/node_modules/tinytim/test/render-replace.js +0 -0
- /package/{test → app}/node_modules/tinytim/test/tim-replace.js +0 -0
- /package/{test → app}/node_modules/tracer/README.md +0 -0
- /package/{test → app}/node_modules/tracer/lib/color_console.js +0 -0
- /package/{test → app}/node_modules/tracer/lib/console.js +0 -0
- /package/{test → app}/node_modules/tracer/lib/dailyfile.js +0 -0
- /package/{test → app}/node_modules/tracer/lib/index.js +0 -0
- /package/{test → app}/node_modules/tracer/lib/settings.js +0 -0
- /package/{test → app}/node_modules/tracer/lib/utils.js +0 -0
- /package/{test → app}/node_modules/tracer/package.json +0 -0
- /package/{test → app}/node_modules/tracer/types/index.d.ts +0 -0
- /package/{test → app}/src/aop-test.class.ts +0 -0
- /package/{test → app}/src/config-production.json +0 -0
- /package/{test → app}/src/entities/mutil-users.class.ts +0 -0
- /package/{test → app}/src/entities/user-dto.class.ts +0 -0
- /package/{test → app}/src/first-page.class.ts +0 -0
- /package/{test → app}/src/second-page.class.ts +0 -0
- /package/{test → app}/src/views/index.html +0 -0
- /package/{test → app}/src/views/upload.html +0 -0
- /package/{test → app}/static/favicon.ico +0 -0
- /package/{test → app}/static/k.jpg +0 -0
- /package/{test → app}/tsconfig.json +0 -0
package/app/nodemon.json
ADDED
|
@@ -9,7 +9,14 @@
|
|
|
9
9
|
},
|
|
10
10
|
"view": {
|
|
11
11
|
"engine": "mustache",
|
|
12
|
-
"path": "/
|
|
12
|
+
"path": "/app/src/views",
|
|
13
13
|
"suffix": "html"
|
|
14
|
+
},
|
|
15
|
+
"rabbitmq": {
|
|
16
|
+
"protocol": "amqp",
|
|
17
|
+
"hostname": "localhost",
|
|
18
|
+
"port": 5672,
|
|
19
|
+
"username": "guest",
|
|
20
|
+
"password": "guest"
|
|
14
21
|
}
|
|
15
22
|
}
|
|
@@ -17,7 +17,7 @@ export default class CustomLog extends LogFactory {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
public log(message?: any, ...optionalParams: any[]) : void{
|
|
20
|
-
this.logger.log(message, ...optionalParams);
|
|
20
|
+
//this.logger.log(message, ...optionalParams);
|
|
21
21
|
}
|
|
22
22
|
|
|
23
23
|
public error(message?: any, ...optionalParams: any[]) : void {
|
|
@@ -11,7 +11,7 @@ const jwtConfig: {
|
|
|
11
11
|
|
|
12
12
|
export default class JwtAuthentication extends AuthenticationFactory {
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
@bean
|
|
15
15
|
public getJwtAuthentication(): AuthenticationFactory {
|
|
16
16
|
return new JwtAuthentication();
|
|
17
17
|
}
|
|
@@ -21,8 +21,9 @@ export default class JwtAuthentication extends AuthenticationFactory {
|
|
|
21
21
|
const jwtMiddleware = expressjwt(jwtConfig);
|
|
22
22
|
jwtMiddleware(req, res, (err) => {
|
|
23
23
|
if (err) {
|
|
24
|
-
next(err);
|
|
24
|
+
//next(err);
|
|
25
25
|
}
|
|
26
|
+
next();
|
|
26
27
|
});
|
|
27
28
|
}
|
|
28
29
|
}
|
package/{test → app}/src/main.ts
RENAMED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { app, log, autoware, ServerFactory } from "../../";
|
|
2
2
|
//import * as basicAuth from "express-basic-auth"
|
|
3
|
+
let appServer = null;
|
|
3
4
|
|
|
4
5
|
@app
|
|
5
6
|
class Main {
|
|
@@ -11,7 +12,13 @@ class Main {
|
|
|
11
12
|
// this.server.setMiddleware(basicAuth({
|
|
12
13
|
// users: { 'admin': 'supersecret' }
|
|
13
14
|
// }));
|
|
14
|
-
this.server.start(8081);
|
|
15
|
+
appServer = this.server.start(8081);
|
|
15
16
|
log('start application');
|
|
16
17
|
}
|
|
17
|
-
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default () => {
|
|
21
|
+
if (appServer != null) {
|
|
22
|
+
appServer.close();
|
|
23
|
+
}
|
|
24
|
+
};
|
|
@@ -18,7 +18,7 @@ export default class TestDatabase {
|
|
|
18
18
|
@getMapping("/db/insert2")
|
|
19
19
|
async insertByObject(req, res) {
|
|
20
20
|
const newId = await this.addRowByObject({
|
|
21
|
-
"id":
|
|
21
|
+
"id": Math.ceil(Math.random() * 1000), "name": "new name 25"
|
|
22
22
|
});
|
|
23
23
|
log("Insert newId: " + newId);
|
|
24
24
|
res.send("Insert success");
|
|
@@ -8,7 +8,7 @@ export default class TestMq {
|
|
|
8
8
|
@autoware
|
|
9
9
|
private rabbitMQ: RabbitMQ;
|
|
10
10
|
|
|
11
|
-
|
|
11
|
+
@rabbitListener("myqueues")
|
|
12
12
|
public async listen(message) {
|
|
13
13
|
log(" Received by Decorator '%s'", message.content.toString());
|
|
14
14
|
}
|
|
@@ -31,9 +31,8 @@ export default class TestMq {
|
|
|
31
31
|
password: 'guest'
|
|
32
32
|
});
|
|
33
33
|
const channel = await connection.createChannel();
|
|
34
|
-
await channel.
|
|
34
|
+
await channel.assertQueue(queue);
|
|
35
35
|
channel.sendToQueue(queue, Buffer.from(text));
|
|
36
|
-
console.log(" [x] Sent by queue '%s'", text);
|
|
37
36
|
await channel.close();
|
|
38
37
|
return "sent by queue";
|
|
39
38
|
}
|
|
@@ -46,7 +45,6 @@ export default class TestMq {
|
|
|
46
45
|
const channel = await connection.createChannel();
|
|
47
46
|
await channel.checkExchange(exchange);
|
|
48
47
|
channel.publish(exchange, '', Buffer.from(text));
|
|
49
|
-
console.log(" [x] Publish by exchange '%s'", text);
|
|
50
48
|
await channel.close();
|
|
51
49
|
return "sent by exchange";
|
|
52
50
|
}
|
|
@@ -60,10 +58,8 @@ export default class TestMq {
|
|
|
60
58
|
await channel.checkQueue(queue);
|
|
61
59
|
await channel.checkQueue(queue2);
|
|
62
60
|
await channel.consume(queue, (message) => {
|
|
63
|
-
console.log(" [x] Received '%s'", message.content.toString());
|
|
64
61
|
}, { noAck: true });
|
|
65
62
|
await channel.consume(queue2, (message) => {
|
|
66
|
-
console.log(" [x] Received queue2 '%s'", message.content.toString());
|
|
67
63
|
}, { noAck: true });
|
|
68
64
|
return "ok";
|
|
69
65
|
}
|
|
@@ -38,33 +38,33 @@ export default class TestOrm {
|
|
|
38
38
|
|
|
39
39
|
@getMapping("/orm/count")
|
|
40
40
|
async countTest(req, res) {
|
|
41
|
-
const
|
|
42
|
-
res.send(
|
|
41
|
+
const total = await this.userModel.count();
|
|
42
|
+
res.send({"count": total});
|
|
43
43
|
}
|
|
44
44
|
|
|
45
45
|
@getMapping("/orm/new")
|
|
46
46
|
async newUserTest(req, res) {
|
|
47
|
-
const
|
|
48
|
-
res.send("
|
|
47
|
+
const newId = await this.userModel.newUsers();
|
|
48
|
+
res.send({"newId": newId});
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
@getMapping("/orm/page/calculate")
|
|
52
52
|
async calculatePage(req, res) {
|
|
53
53
|
const pages = this.userModel.pager(15, 376);
|
|
54
|
-
res.
|
|
54
|
+
res.json(pages);
|
|
55
55
|
}
|
|
56
56
|
|
|
57
57
|
@getMapping("/orm/pages/:id")
|
|
58
58
|
async findPage(req, res) {
|
|
59
59
|
const results = await this.userModel.findAll("1", { id: -1 }, "*", { page: req.params.id, pageSize: 3 });
|
|
60
60
|
log(this.userModel.page);
|
|
61
|
-
res.
|
|
61
|
+
res.json(results);
|
|
62
62
|
}
|
|
63
63
|
|
|
64
64
|
@postMapping("/orm/edit")
|
|
65
65
|
async updateTest(req, res) {
|
|
66
|
-
const
|
|
67
|
-
res.send(
|
|
66
|
+
const effectRows = await this.userModel.editUser(req.body.id, req.body.name);
|
|
67
|
+
res.send({"effectRows": effectRows});
|
|
68
68
|
}
|
|
69
69
|
|
|
70
70
|
//@schedule("* * * * * *")
|
|
@@ -18,20 +18,20 @@ export default class TestRequest {
|
|
|
18
18
|
}
|
|
19
19
|
|
|
20
20
|
@postMapping("/request/body")
|
|
21
|
-
testBody(@res res, @reqBody body:
|
|
21
|
+
testBody(@res res, @reqBody body: UserDto):MutilUsers {
|
|
22
22
|
log("body: " + JSON.stringify(body));
|
|
23
|
-
return new MutilUsers("group", [
|
|
23
|
+
return new MutilUsers("group", [body]);
|
|
24
24
|
}
|
|
25
25
|
|
|
26
26
|
@postMapping("/request/form")
|
|
27
27
|
testForm(@res res, @reqForm("name") name: string) {
|
|
28
28
|
log("form: " + JSON.stringify(name));
|
|
29
|
-
res.send("
|
|
29
|
+
res.send("Got name: " + name);
|
|
30
30
|
}
|
|
31
31
|
|
|
32
32
|
@getMapping("/request/param/:id")
|
|
33
33
|
testParam(@res res, @reqParam id: number) {
|
|
34
34
|
log("id: " + id);
|
|
35
|
-
res.send("test param");
|
|
35
|
+
res.send("test param: " + id);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
@@ -8,24 +8,25 @@ export default class UserModel extends Model {
|
|
|
8
8
|
const users = await this.findAll({
|
|
9
9
|
id: { $lt: 10, $lte: 20 }, "name": { $like: "%a%" },
|
|
10
10
|
$or: [{ id: 1 }, { id: 2 }]
|
|
11
|
-
});
|
|
11
|
+
}, "id asc", "*", { page: 1, pageSize: 10 });
|
|
12
12
|
log("users", users);
|
|
13
13
|
return "getUsers";
|
|
14
14
|
}
|
|
15
15
|
|
|
16
16
|
async getUser(id: number) {
|
|
17
|
-
const user = await this.find({ id: id }, "");
|
|
17
|
+
const user = await this.find({ id: id }, "id asc", "*");
|
|
18
18
|
log("user", user);
|
|
19
19
|
return "getUser";
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
async newUsers() {
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
new UserDto(
|
|
26
|
-
|
|
23
|
+
const newId = Math.ceil(Math.random() * 1000);
|
|
24
|
+
await this.create([
|
|
25
|
+
new UserDto(newId, "UserDto " + newId),
|
|
26
|
+
new UserDto(newId+1, "UserDto " + (newId+1)),
|
|
27
|
+
{ id: newId+2, name: "UserDto " + (newId+2) },
|
|
27
28
|
]);
|
|
28
|
-
return
|
|
29
|
+
return newId;
|
|
29
30
|
}
|
|
30
31
|
|
|
31
32
|
async remove(id: number) {
|
|
@@ -33,13 +34,13 @@ export default class UserModel extends Model {
|
|
|
33
34
|
return "remove rows: " + result;
|
|
34
35
|
}
|
|
35
36
|
|
|
36
|
-
async count() {
|
|
37
|
+
async count():Promise<number> {
|
|
37
38
|
const result = await this.findCount("1");
|
|
38
|
-
return
|
|
39
|
+
return result;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
async editUser(id: number, name: string) {
|
|
42
|
-
const
|
|
43
|
-
return
|
|
43
|
+
const effectRows = await this.update({ id: id }, { name: name });
|
|
44
|
+
return effectRows;
|
|
44
45
|
}
|
|
45
46
|
}
|
package/dist/core.decorator.js
CHANGED
|
@@ -1,54 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.schedule = exports.getComponent = exports.getBean = exports.autoware = exports.
|
|
3
|
+
exports.schedule = exports.getComponent = exports.getBean = exports.autoware = exports.error = exports.log = exports.resource = exports.bean = exports.component = void 0;
|
|
4
4
|
require("reflect-metadata");
|
|
5
|
-
const fs = require("fs");
|
|
6
|
-
const path = require("path");
|
|
7
|
-
const walkSync = require("walk-sync");
|
|
8
5
|
const cron = require("cron");
|
|
9
6
|
const log_factory_class_1 = require("./factory/log-factory.class");
|
|
10
|
-
let globalConfig = {};
|
|
11
7
|
const resourceObjects = new Map();
|
|
12
8
|
const beanMapper = new Map();
|
|
13
9
|
const objectMapper = new Map();
|
|
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
|
-
const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
|
|
27
|
-
const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
|
|
28
|
-
(async function () {
|
|
29
|
-
try {
|
|
30
|
-
for (let p of coreFiles) {
|
|
31
|
-
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
32
|
-
await Promise.resolve().then(() => require(coreDir + "/" + moduleName));
|
|
33
|
-
}
|
|
34
|
-
for (let p of mainFiles) {
|
|
35
|
-
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
36
|
-
await Promise.resolve().then(() => require(mainPath + "/" + moduleName));
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
catch (err) {
|
|
40
|
-
console.error(err);
|
|
41
|
-
}
|
|
42
|
-
//log("main start")
|
|
43
|
-
const main = new constructor();
|
|
44
|
-
main["main"]();
|
|
45
|
-
}());
|
|
46
|
-
}
|
|
47
|
-
exports.app = app;
|
|
48
|
-
function config(node) {
|
|
49
|
-
return globalConfig[node] || null;
|
|
50
|
-
}
|
|
51
|
-
exports.config = config;
|
|
52
10
|
function component(constructorFunction) {
|
|
53
11
|
objectMapper.set(constructorFunction.name, new constructorFunction());
|
|
54
12
|
}
|
|
@@ -71,30 +29,6 @@ function getBean(mappingClass) {
|
|
|
71
29
|
return bean["factory"];
|
|
72
30
|
}
|
|
73
31
|
exports.getBean = getBean;
|
|
74
|
-
function value(configPath) {
|
|
75
|
-
return function (target, propertyKey) {
|
|
76
|
-
if (globalConfig === undefined) {
|
|
77
|
-
Object.defineProperty(target, propertyKey, {
|
|
78
|
-
get: () => {
|
|
79
|
-
return undefined;
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
let pathNodes = configPath.split(".");
|
|
85
|
-
let nodeValue = globalConfig;
|
|
86
|
-
for (let i = 0; i < pathNodes.length; i++) {
|
|
87
|
-
nodeValue = nodeValue[pathNodes[i]];
|
|
88
|
-
}
|
|
89
|
-
Object.defineProperty(target, propertyKey, {
|
|
90
|
-
get: () => {
|
|
91
|
-
return nodeValue;
|
|
92
|
-
}
|
|
93
|
-
});
|
|
94
|
-
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
exports.value = value;
|
|
98
32
|
function autoware(target, propertyKey) {
|
|
99
33
|
const type = Reflect.getMetadata("design:type", target, propertyKey);
|
|
100
34
|
Object.defineProperty(target, propertyKey, {
|
|
@@ -147,23 +81,6 @@ function error(message, ...optionalParams) {
|
|
|
147
81
|
}
|
|
148
82
|
}
|
|
149
83
|
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
|
-
}
|
|
167
84
|
function schedule(cronTime) {
|
|
168
85
|
return (target, propertyKey) => {
|
|
169
86
|
new cron.CronJob(cronTime, target[propertyKey]).start();
|
|
@@ -74,7 +74,7 @@ function select(sql) {
|
|
|
74
74
|
exports.select = select;
|
|
75
75
|
function resultType(dataClass) {
|
|
76
76
|
return function (target, propertyKey) {
|
|
77
|
-
resultTypeMap.set([target.constructor.name, propertyKey].toString(),
|
|
77
|
+
resultTypeMap.set([target.constructor.name, propertyKey].toString(), dataClass);
|
|
78
78
|
//never return
|
|
79
79
|
};
|
|
80
80
|
}
|
|
@@ -19,6 +19,7 @@ const expressSession = require("express-session");
|
|
|
19
19
|
const connectRedis = require("connect-redis");
|
|
20
20
|
const server_factory_class_1 = require("../factory/server-factory.class");
|
|
21
21
|
const route_decorator_1 = require("../route.decorator");
|
|
22
|
+
const typespeed_1 = require("../typespeed");
|
|
22
23
|
const core_decorator_1 = require("../core.decorator");
|
|
23
24
|
const redis_class_1 = require("./redis.class");
|
|
24
25
|
const authentication_factory_class_1 = require("../factory/authentication-factory.class");
|
|
@@ -31,15 +32,13 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
31
32
|
setMiddleware(middleware) {
|
|
32
33
|
this.middlewareList.push(middleware);
|
|
33
34
|
}
|
|
34
|
-
start(port) {
|
|
35
|
+
start(port, callback) {
|
|
35
36
|
this.app.use(this.authentication.afterCompletion);
|
|
36
37
|
this.middlewareList.forEach(middleware => {
|
|
37
38
|
this.app.use(middleware);
|
|
38
39
|
});
|
|
39
40
|
this.setDefaultMiddleware();
|
|
40
|
-
return this.app.listen(port,
|
|
41
|
-
(0, core_decorator_1.log)("server start at port: " + port);
|
|
42
|
-
});
|
|
41
|
+
return this.app.listen(port, callback);
|
|
43
42
|
}
|
|
44
43
|
setDefaultMiddleware() {
|
|
45
44
|
this.app.use(express.urlencoded({ extended: true }));
|
|
@@ -110,31 +109,31 @@ class ExpressServer extends server_factory_class_1.default {
|
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
__decorate([
|
|
113
|
-
(0,
|
|
112
|
+
(0, typespeed_1.value)("view"),
|
|
114
113
|
__metadata("design:type", String)
|
|
115
114
|
], ExpressServer.prototype, "view", void 0);
|
|
116
115
|
__decorate([
|
|
117
|
-
(0,
|
|
116
|
+
(0, typespeed_1.value)("static"),
|
|
118
117
|
__metadata("design:type", String)
|
|
119
118
|
], ExpressServer.prototype, "static", void 0);
|
|
120
119
|
__decorate([
|
|
121
|
-
(0,
|
|
120
|
+
(0, typespeed_1.value)("favicon"),
|
|
122
121
|
__metadata("design:type", String)
|
|
123
122
|
], ExpressServer.prototype, "favicon", void 0);
|
|
124
123
|
__decorate([
|
|
125
|
-
(0,
|
|
124
|
+
(0, typespeed_1.value)("compression"),
|
|
126
125
|
__metadata("design:type", Object)
|
|
127
126
|
], ExpressServer.prototype, "compression", void 0);
|
|
128
127
|
__decorate([
|
|
129
|
-
(0,
|
|
128
|
+
(0, typespeed_1.value)("cookie"),
|
|
130
129
|
__metadata("design:type", Object)
|
|
131
130
|
], ExpressServer.prototype, "cookieConfig", void 0);
|
|
132
131
|
__decorate([
|
|
133
|
-
(0,
|
|
132
|
+
(0, typespeed_1.value)("session"),
|
|
134
133
|
__metadata("design:type", Object)
|
|
135
134
|
], ExpressServer.prototype, "session", void 0);
|
|
136
135
|
__decorate([
|
|
137
|
-
(0,
|
|
136
|
+
(0, typespeed_1.value)("redis"),
|
|
138
137
|
__metadata("design:type", Object)
|
|
139
138
|
], ExpressServer.prototype, "redisConfig", void 0);
|
|
140
139
|
__decorate([
|
|
@@ -11,6 +11,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const cache_factory_class_1 = require("../factory/cache-factory.class");
|
|
13
13
|
const cache = require("node-cache");
|
|
14
|
+
const typespeed_1 = require("../typespeed");
|
|
14
15
|
const core_decorator_1 = require("../core.decorator");
|
|
15
16
|
class NodeCache extends cache_factory_class_1.default {
|
|
16
17
|
constructor() {
|
|
@@ -38,7 +39,7 @@ class NodeCache extends cache_factory_class_1.default {
|
|
|
38
39
|
}
|
|
39
40
|
}
|
|
40
41
|
__decorate([
|
|
41
|
-
(0,
|
|
42
|
+
(0, typespeed_1.value)("cache"),
|
|
42
43
|
__metadata("design:type", Object)
|
|
43
44
|
], NodeCache.prototype, "config", void 0);
|
|
44
45
|
__decorate([
|
|
@@ -11,11 +11,12 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.rabbitListener = exports.RabbitMQ = void 0;
|
|
13
13
|
const core_decorator_1 = require("../core.decorator");
|
|
14
|
+
const typespeed_1 = require("../typespeed");
|
|
14
15
|
const amqplib_1 = require("amqplib");
|
|
15
16
|
let rabbitConnection = null;
|
|
16
17
|
class RabbitMQ {
|
|
17
18
|
getRabbitMQ() {
|
|
18
|
-
if (!(0,
|
|
19
|
+
if (!(0, typespeed_1.config)("rabbitmq")) {
|
|
19
20
|
return null;
|
|
20
21
|
}
|
|
21
22
|
return new RabbitMQ();
|
|
@@ -48,7 +49,7 @@ __decorate([
|
|
|
48
49
|
exports.RabbitMQ = RabbitMQ;
|
|
49
50
|
async function getChannel() {
|
|
50
51
|
if (rabbitConnection === null) {
|
|
51
|
-
rabbitConnection = await (0, amqplib_1.connect)((0,
|
|
52
|
+
rabbitConnection = await (0, amqplib_1.connect)((0, typespeed_1.config)("rabbitmq"));
|
|
52
53
|
process.once('SIGINT', async () => {
|
|
53
54
|
await rabbitConnection.close();
|
|
54
55
|
});
|
|
@@ -12,10 +12,17 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
const mysql2_1 = require("mysql2");
|
|
13
13
|
const data_source_factory_class_1 = require("../factory/data-source-factory.class");
|
|
14
14
|
const core_decorator_1 = require("../core.decorator");
|
|
15
|
+
const typespeed_1 = require("../typespeed");
|
|
15
16
|
class ReadWriteDb extends data_source_factory_class_1.default {
|
|
17
|
+
getDataSource() {
|
|
18
|
+
if (!(0, typespeed_1.config)("mysql")) {
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
return new ReadWriteDb();
|
|
22
|
+
}
|
|
16
23
|
constructor() {
|
|
17
24
|
super();
|
|
18
|
-
const dbConfig = (0,
|
|
25
|
+
const dbConfig = (0, typespeed_1.config)("mysql");
|
|
19
26
|
if (dbConfig["master"] && dbConfig["slave"]) {
|
|
20
27
|
this.writeSession = this.getConnectionByConfig(dbConfig["master"]);
|
|
21
28
|
if (Array.isArray(dbConfig["slave"])) {
|
|
@@ -30,12 +37,6 @@ class ReadWriteDb extends data_source_factory_class_1.default {
|
|
|
30
37
|
this.readSession = [this.writeSession];
|
|
31
38
|
}
|
|
32
39
|
}
|
|
33
|
-
getDataSource() {
|
|
34
|
-
if (!(0, core_decorator_1.config)("mysql")) {
|
|
35
|
-
return null;
|
|
36
|
-
}
|
|
37
|
-
return new ReadWriteDb();
|
|
38
|
-
}
|
|
39
40
|
getConnectionByConfig(config) {
|
|
40
41
|
if (config["PoolOptions"] !== undefined) {
|
|
41
42
|
// we need pool
|
|
@@ -11,12 +11,13 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
const core_decorator_1 = require("../core.decorator");
|
|
13
13
|
const ioredis_1 = require("ioredis");
|
|
14
|
+
const typespeed_1 = require("../typespeed");
|
|
14
15
|
class Redis extends ioredis_1.default {
|
|
15
16
|
getRedis() {
|
|
16
|
-
if (!(0,
|
|
17
|
+
if (!(0, typespeed_1.config)("redis")) {
|
|
17
18
|
return null;
|
|
18
19
|
}
|
|
19
|
-
return new Redis((0,
|
|
20
|
+
return new Redis((0, typespeed_1.config)("redis"));
|
|
20
21
|
}
|
|
21
22
|
constructor(config) {
|
|
22
23
|
super(config);
|
package/dist/typespeed.js
CHANGED
|
@@ -14,7 +14,91 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.ReadWriteDb = exports.Redis = exports.NodeCache = exports.LogDefault = exports.ExpressServer = exports.AuthenticationFactory = exports.ServerFactory = exports.DataSourceFactory = exports.CacheFactory = exports.LogFactory = void 0;
|
|
17
|
+
exports.ReadWriteDb = exports.Redis = exports.NodeCache = exports.LogDefault = exports.ExpressServer = exports.AuthenticationFactory = exports.ServerFactory = exports.DataSourceFactory = exports.CacheFactory = exports.LogFactory = exports.config = exports.value = exports.app = void 0;
|
|
18
|
+
require("reflect-metadata");
|
|
19
|
+
const fs = require("fs");
|
|
20
|
+
const path = require("path");
|
|
21
|
+
const walkSync = require("walk-sync");
|
|
22
|
+
let globalConfig = {};
|
|
23
|
+
const coreDir = __dirname;
|
|
24
|
+
const mainPath = path.dirname(getRootPath(new Error().stack.split("\n")) || process.argv[1]);
|
|
25
|
+
const configFile = mainPath + "/config.json";
|
|
26
|
+
if (fs.existsSync(configFile)) {
|
|
27
|
+
globalConfig = JSON.parse(fs.readFileSync(configFile, "utf-8"));
|
|
28
|
+
const nodeEnv = process.env.NODE_ENV || "development";
|
|
29
|
+
const envConfigFile = mainPath + "/config-" + nodeEnv + ".json";
|
|
30
|
+
if (fs.existsSync(envConfigFile)) {
|
|
31
|
+
globalConfig = Object.assign(globalConfig, JSON.parse(fs.readFileSync(envConfigFile, "utf-8")));
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
function app(constructor) {
|
|
35
|
+
const coreFiles = walkSync(coreDir, { globs: ['**/*.ts'], ignore: ['**/*.d.ts', 'scaffold/**'] });
|
|
36
|
+
const mainFiles = walkSync(mainPath, { globs: ['**/*.ts'] });
|
|
37
|
+
(async function () {
|
|
38
|
+
var _a, _b;
|
|
39
|
+
try {
|
|
40
|
+
for (let p of coreFiles) {
|
|
41
|
+
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
42
|
+
await (_a = coreDir + "/" + moduleName, Promise.resolve().then(() => require(_a)));
|
|
43
|
+
}
|
|
44
|
+
for (let p of mainFiles) {
|
|
45
|
+
let moduleName = p.replace(".d.ts", "").replace(".ts", "");
|
|
46
|
+
await (_b = mainPath + "/" + moduleName, Promise.resolve().then(() => require(_b)));
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
catch (err) {
|
|
50
|
+
console.error(err);
|
|
51
|
+
}
|
|
52
|
+
//log("main start")
|
|
53
|
+
const main = new constructor();
|
|
54
|
+
main["main"]();
|
|
55
|
+
}());
|
|
56
|
+
}
|
|
57
|
+
exports.app = app;
|
|
58
|
+
function config(node) {
|
|
59
|
+
return globalConfig[node] || null;
|
|
60
|
+
}
|
|
61
|
+
exports.config = config;
|
|
62
|
+
function value(configPath) {
|
|
63
|
+
return function (target, propertyKey) {
|
|
64
|
+
if (globalConfig === undefined) {
|
|
65
|
+
Object.defineProperty(target, propertyKey, {
|
|
66
|
+
get: () => {
|
|
67
|
+
return undefined;
|
|
68
|
+
}
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
let pathNodes = configPath.split(".");
|
|
73
|
+
let nodeValue = globalConfig;
|
|
74
|
+
for (let i = 0; i < pathNodes.length; i++) {
|
|
75
|
+
nodeValue = nodeValue[pathNodes[i]];
|
|
76
|
+
}
|
|
77
|
+
Object.defineProperty(target, propertyKey, {
|
|
78
|
+
get: () => {
|
|
79
|
+
return nodeValue;
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
exports.value = value;
|
|
86
|
+
function getRootPath(lines) {
|
|
87
|
+
const macths = ["at Function.Module._load", "at Module.require", "at require", "at Object.<anonymous>"];
|
|
88
|
+
let matchIndex = 0;
|
|
89
|
+
for (let line of lines) {
|
|
90
|
+
if (line.includes(macths[matchIndex])) {
|
|
91
|
+
if (matchIndex === macths.length - 1) {
|
|
92
|
+
return line.split("(")[1].split(":")[0];
|
|
93
|
+
}
|
|
94
|
+
matchIndex++;
|
|
95
|
+
}
|
|
96
|
+
else {
|
|
97
|
+
matchIndex = 0;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return undefined;
|
|
101
|
+
}
|
|
18
102
|
__exportStar(require("./core.decorator"), exports);
|
|
19
103
|
__exportStar(require("./route.decorator"), exports);
|
|
20
104
|
__exportStar(require("./database.decorator"), exports);
|