@nest-omni/core 2.0.1-2 → 2.0.1-4
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/package.json +6 -3
- package/setup/bootstrap.setup.js +50 -23
- package/shared/serviceRegistryModule.js +2 -34
- package/tsconfig.tsbuildinfo +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-omni/core",
|
|
3
|
-
"version": "2.0.1-
|
|
3
|
+
"version": "2.0.1-4",
|
|
4
4
|
"description": "framework",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"types": "index.d.ts",
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"author": "Jinpy",
|
|
18
18
|
"license": "Apache-2.0",
|
|
19
19
|
"devDependencies": {
|
|
20
|
-
"typescript": "^5.4.5"
|
|
20
|
+
"typescript": "^5.4.5",
|
|
21
|
+
"@types/compression": "^1.8.1"
|
|
21
22
|
},
|
|
22
23
|
"peerDependencies": {
|
|
23
24
|
"@dataui/crud": "^5.3.0",
|
|
@@ -65,6 +66,8 @@
|
|
|
65
66
|
"uuid": "^9.0.1"
|
|
66
67
|
},
|
|
67
68
|
"dependencies": {
|
|
68
|
-
"hygen": "^6.2.11"
|
|
69
|
+
"hygen": "^6.2.11",
|
|
70
|
+
"nestjs-cls": "^4.3.0",
|
|
71
|
+
"compression": "^1.8.0"
|
|
69
72
|
}
|
|
70
73
|
}
|
package/setup/bootstrap.setup.js
CHANGED
|
@@ -15,18 +15,45 @@ const profiling_node_1 = require("@sentry/profiling-node");
|
|
|
15
15
|
const dotenv = require("dotenv");
|
|
16
16
|
const fs_1 = require("fs");
|
|
17
17
|
const path_1 = require("path");
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
const
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
18
|
+
const process = require("process");
|
|
19
|
+
function findValidRootPath() {
|
|
20
|
+
const possibleRootPaths = [
|
|
21
|
+
(0, path_1.dirname)(process.argv[1]),
|
|
22
|
+
process.cwd(),
|
|
23
|
+
__dirname,
|
|
24
|
+
];
|
|
25
|
+
const envFile = `${process.env.NODE_ENV || ''}.env`;
|
|
26
|
+
const isTest = process.env.NODE_ENV === 'test';
|
|
27
|
+
let envFilePath = '';
|
|
28
|
+
for (const rootPath of possibleRootPaths) {
|
|
29
|
+
const configPath = (0, path_1.join)(rootPath, 'config');
|
|
30
|
+
const baseEnvFilePath = (0, path_1.join)(configPath, 'base.env');
|
|
31
|
+
if (isTest) {
|
|
32
|
+
envFilePath = (0, path_1.join)(configPath, 'test.env');
|
|
33
|
+
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
34
|
+
return { rootPath, baseEnvFilePath, envFilePath };
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
envFilePath = (0, path_1.join)(configPath, 'dev.env');
|
|
38
|
+
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
39
|
+
return { rootPath, baseEnvFilePath, envFilePath };
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
else {
|
|
44
|
+
envFilePath = (0, path_1.join)(configPath, envFile);
|
|
45
|
+
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
46
|
+
return { rootPath, baseEnvFilePath, envFilePath };
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new Error(`No valid .env file: ${envFilePath}`);
|
|
29
51
|
}
|
|
52
|
+
const { envFilePath, rootPath, baseEnvFilePath } = findValidRootPath();
|
|
53
|
+
dotenv.config({ path: [envFilePath, baseEnvFilePath] });
|
|
54
|
+
process.env.ROOT_PATH = rootPath;
|
|
55
|
+
process.env.ENV_FILE_PATH = envFilePath;
|
|
56
|
+
process.env.BASE_ENV_FILE_PATH = baseEnvFilePath;
|
|
30
57
|
const requiredEnvVars = ['SENTRY_DSN', 'API_VERSION', 'NODE_ENV'];
|
|
31
58
|
requiredEnvVars.forEach((envVar) => {
|
|
32
59
|
if (!process.env[envVar]) {
|
|
@@ -45,6 +72,18 @@ Sentry.init({
|
|
|
45
72
|
integrations: [profiling_node_1.nodeProfilingIntegration],
|
|
46
73
|
});
|
|
47
74
|
const crud_1 = require("@dataui/crud");
|
|
75
|
+
const core_1 = require("@nestjs/core");
|
|
76
|
+
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
77
|
+
const nestjs_pino_1 = require("nestjs-pino");
|
|
78
|
+
const session = require("express-session");
|
|
79
|
+
const bodyParse = require("body-parser");
|
|
80
|
+
const __1 = require("../");
|
|
81
|
+
const common_1 = require("@nestjs/common");
|
|
82
|
+
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
83
|
+
const nestjs_cls_1 = require("nestjs-cls");
|
|
84
|
+
const compression = require("compression");
|
|
85
|
+
const class_validator_1 = require("class-validator");
|
|
86
|
+
const setup_1 = require("@sentry/nestjs/setup");
|
|
48
87
|
crud_1.CrudConfigService.load({
|
|
49
88
|
auth: {
|
|
50
89
|
property: 'user',
|
|
@@ -72,18 +111,6 @@ crud_1.CrudConfigService.load({
|
|
|
72
111
|
},
|
|
73
112
|
},
|
|
74
113
|
});
|
|
75
|
-
const core_1 = require("@nestjs/core");
|
|
76
|
-
const typeorm_transactional_1 = require("typeorm-transactional");
|
|
77
|
-
const nestjs_pino_1 = require("nestjs-pino");
|
|
78
|
-
const session = require("express-session");
|
|
79
|
-
const bodyParse = require("body-parser");
|
|
80
|
-
const __1 = require("../");
|
|
81
|
-
const common_1 = require("@nestjs/common");
|
|
82
|
-
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
83
|
-
const nestjs_cls_1 = require("nestjs-cls");
|
|
84
|
-
const compression = require("compression");
|
|
85
|
-
const class_validator_1 = require("class-validator");
|
|
86
|
-
const setup_1 = require("@sentry/nestjs/setup");
|
|
87
114
|
const setupProcessHandlers = (app) => {
|
|
88
115
|
const logger = app.get(nestjs_pino_1.Logger);
|
|
89
116
|
process.on('uncaughtException', (error) => {
|
|
@@ -31,8 +31,6 @@ const typeorm_transactional_1 = require("typeorm-transactional");
|
|
|
31
31
|
const nestjs_i18n_1 = require("nestjs-i18n");
|
|
32
32
|
const health_checker_module_1 = require("../health-checker/health-checker.module");
|
|
33
33
|
const services_1 = require("./services");
|
|
34
|
-
const fs_1 = require("fs");
|
|
35
|
-
const path_1 = require("path");
|
|
36
34
|
const nestjs_cls_1 = require("nestjs-cls");
|
|
37
35
|
const providers = [
|
|
38
36
|
services_1.ApiConfigService,
|
|
@@ -40,44 +38,14 @@ const providers = [
|
|
|
40
38
|
services_1.GeneratorService,
|
|
41
39
|
services_1.TranslationService,
|
|
42
40
|
];
|
|
43
|
-
|
|
44
|
-
function findValidRootPath() {
|
|
45
|
-
const possibleRootPaths = [process.cwd(), __dirname];
|
|
46
|
-
const envFile = `${process.env.NODE_ENV || ''}.env`;
|
|
47
|
-
let envFilePath = '';
|
|
48
|
-
for (const rootPath of possibleRootPaths) {
|
|
49
|
-
const configPath = (0, path_1.join)(rootPath, 'config');
|
|
50
|
-
const baseEnvFilePath = (0, path_1.join)(configPath, 'base.env');
|
|
51
|
-
if (isTest) {
|
|
52
|
-
envFilePath = (0, path_1.join)(configPath, 'test.env');
|
|
53
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
54
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
55
|
-
}
|
|
56
|
-
else {
|
|
57
|
-
envFilePath = (0, path_1.join)(configPath, 'dev.env');
|
|
58
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
59
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
else {
|
|
64
|
-
envFilePath = (0, path_1.join)(configPath, envFile);
|
|
65
|
-
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
66
|
-
return { rootPath, baseEnvFilePath, envFilePath };
|
|
67
|
-
}
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
throw new Error(`No valid .env file: ${envFilePath}`);
|
|
71
|
-
}
|
|
72
|
-
const { envFilePath, rootPath, baseEnvFilePath } = findValidRootPath();
|
|
73
|
-
services_1.ApiConfigService.rootPath = rootPath;
|
|
41
|
+
services_1.ApiConfigService.rootPath = process.env.ROOT_PATH;
|
|
74
42
|
const modules = [
|
|
75
43
|
setup_1.SentryModule.forRoot(),
|
|
76
44
|
config_1.ConfigModule.forRoot({
|
|
77
45
|
isGlobal: true,
|
|
78
46
|
cache: true,
|
|
79
47
|
expandVariables: false,
|
|
80
|
-
envFilePath: [
|
|
48
|
+
envFilePath: [process.env.ENV_FILE_PATH, process.env.BASE_ENV_FILE_PATH],
|
|
81
49
|
}),
|
|
82
50
|
nestjs_cls_1.ClsModule.forRoot({
|
|
83
51
|
global: true,
|