@nest-omni/core 2.0.1-10 → 2.0.1-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.
@@ -15,7 +15,7 @@ function getOmniAuthData(request, key) {
15
15
  let user;
16
16
  const configService = new config_1.ConfigService(request);
17
17
  if ((0, lodash_1.isEmpty)(headers['x-user-id']) && (0, lodash_1.isEmpty)(headers['x-app-id'])) {
18
- if (process.env.NODE_ENV === 'dev' || process.env.MOCK_ENABLED === 'true') {
18
+ if (process.env.NODE_ENV === 'dev') {
19
19
  user = {
20
20
  uid: configService.get('MOCK_UID'),
21
21
  username: configService.get('MOCK_USERNAME'),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nest-omni/core",
3
- "version": "2.0.1-10",
3
+ "version": "2.0.1-2",
4
4
  "description": "framework",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -17,8 +17,7 @@
17
17
  "author": "Jinpy",
18
18
  "license": "Apache-2.0",
19
19
  "devDependencies": {
20
- "typescript": "^5.4.5",
21
- "@types/compression": "^1.8.1"
20
+ "typescript": "^5.4.5"
22
21
  },
23
22
  "peerDependencies": {
24
23
  "@dataui/crud": "^5.3.0",
@@ -34,6 +33,8 @@
34
33
  "@nestjs/schedule": "^3.0.3",
35
34
  "@nestjs/swagger": "^7.1.11",
36
35
  "@nestjs/terminus": "^10.1.1",
36
+ "@sentry/nestjs": "^10.10.0",
37
+ "@sentry/profiling-node": "^10.10.0",
37
38
  "@nestjs/typeorm": "^10.0.0",
38
39
  "axios": "^1.5.0",
39
40
  "axios-retry": "^3.7.0",
@@ -64,13 +65,6 @@
64
65
  "uuid": "^9.0.1"
65
66
  },
66
67
  "dependencies": {
67
- "hygen": "^6.2.11",
68
- "nestjs-cls": "^4.3.0",
69
- "compression": "^1.8.0",
70
- "@sentry/nestjs": "~9.17.0",
71
- "@sentry/profiling-node": "~9.17.0"
72
- },
73
- "overrides": {
74
- "@sentry-internal/node-cpu-profiler": "2.1.0"
68
+ "hygen": "^6.2.11"
75
69
  }
76
70
  }
@@ -15,50 +15,18 @@ 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 process = require("process");
19
- function findValidRootPath() {
20
- const getAppRootPath = () => {
21
- if (require.main && require.main.filename) {
22
- return (0, path_1.dirname)(require.main.filename);
23
- }
24
- if (process.argv[1]) {
25
- return (0, path_1.dirname)(process.argv[1]);
26
- }
27
- return process.cwd();
28
- };
29
- const possibleRootPaths = [getAppRootPath(), process.cwd(), __dirname];
30
- const envFile = `${process.env.NODE_ENV || ''}.env`;
31
- const isTest = process.env.NODE_ENV === 'test';
32
- let envFilePath = '';
33
- for (const rootPath of possibleRootPaths) {
34
- const configPath = (0, path_1.join)(rootPath, 'config');
35
- const baseEnvFilePath = (0, path_1.join)(configPath, 'base.env');
36
- if (isTest) {
37
- envFilePath = (0, path_1.join)(configPath, 'test.env');
38
- if ((0, fs_1.existsSync)(envFilePath)) {
39
- return { rootPath, baseEnvFilePath, envFilePath };
40
- }
41
- else {
42
- envFilePath = (0, path_1.join)(configPath, 'dev.env');
43
- if ((0, fs_1.existsSync)(envFilePath)) {
44
- return { rootPath, baseEnvFilePath, envFilePath };
45
- }
46
- }
47
- }
48
- else {
49
- envFilePath = (0, path_1.join)(configPath, envFile);
50
- if ((0, fs_1.existsSync)(envFilePath)) {
51
- return { rootPath, baseEnvFilePath, envFilePath };
52
- }
53
- }
54
- }
55
- throw new Error(`No valid .env file: ${envFilePath}`);
18
+ const possibleRootPaths = [process.cwd(), __dirname];
19
+ const path0 = (0, path_1.join)(possibleRootPaths[0], 'config/base.env');
20
+ const path1 = (0, path_1.join)(possibleRootPaths[1], 'config/base.env');
21
+ if ((0, fs_1.existsSync)(path0)) {
22
+ dotenv.config({ path: path0 });
23
+ }
24
+ else if ((0, fs_1.existsSync)(path1)) {
25
+ dotenv.config({ path: path1 });
26
+ }
27
+ else {
28
+ throw new Error(`No valid base.env file: ${path0} or ${path1}`);
56
29
  }
57
- const { envFilePath, rootPath, baseEnvFilePath } = findValidRootPath();
58
- dotenv.config({ path: [envFilePath, baseEnvFilePath] });
59
- process.env.ROOT_PATH = rootPath;
60
- process.env.ENV_FILE_PATH = envFilePath;
61
- process.env.BASE_ENV_FILE_PATH = baseEnvFilePath;
62
30
  const requiredEnvVars = ['SENTRY_DSN', 'API_VERSION', 'NODE_ENV'];
63
31
  requiredEnvVars.forEach((envVar) => {
64
32
  if (!process.env[envVar]) {
@@ -77,18 +45,6 @@ Sentry.init({
77
45
  integrations: [profiling_node_1.nodeProfilingIntegration],
78
46
  });
79
47
  const crud_1 = require("@dataui/crud");
80
- const core_1 = require("@nestjs/core");
81
- const typeorm_transactional_1 = require("typeorm-transactional");
82
- const nestjs_pino_1 = require("nestjs-pino");
83
- const session = require("express-session");
84
- const bodyParse = require("body-parser");
85
- const __1 = require("../");
86
- const common_1 = require("@nestjs/common");
87
- const nestjs_i18n_1 = require("nestjs-i18n");
88
- const nestjs_cls_1 = require("nestjs-cls");
89
- const compression = require("compression");
90
- const class_validator_1 = require("class-validator");
91
- const setup_1 = require("@sentry/nestjs/setup");
92
48
  crud_1.CrudConfigService.load({
93
49
  auth: {
94
50
  property: 'user',
@@ -116,6 +72,18 @@ crud_1.CrudConfigService.load({
116
72
  },
117
73
  },
118
74
  });
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");
119
87
  const setupProcessHandlers = (app) => {
120
88
  const logger = app.get(nestjs_pino_1.Logger);
121
89
  process.on('uncaughtException', (error) => {
@@ -14,7 +14,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
14
14
  step((generator = generator.apply(thisArg, _arguments || [])).next());
15
15
  });
16
16
  };
17
- var _a;
18
17
  Object.defineProperty(exports, "__esModule", { value: true });
19
18
  exports.ServiceRegistryModule = void 0;
20
19
  const path = require("path");
@@ -32,6 +31,8 @@ const typeorm_transactional_1 = require("typeorm-transactional");
32
31
  const nestjs_i18n_1 = require("nestjs-i18n");
33
32
  const health_checker_module_1 = require("../health-checker/health-checker.module");
34
33
  const services_1 = require("./services");
34
+ const fs_1 = require("fs");
35
+ const path_1 = require("path");
35
36
  const nestjs_cls_1 = require("nestjs-cls");
36
37
  const providers = [
37
38
  services_1.ApiConfigService,
@@ -39,17 +40,44 @@ const providers = [
39
40
  services_1.GeneratorService,
40
41
  services_1.TranslationService,
41
42
  ];
42
- if (!((_a = process === null || process === void 0 ? void 0 : process.env) === null || _a === void 0 ? void 0 : _a.ENV_FILE_PATH)) {
43
- require('../setup/bootstrap.setup');
43
+ const isTest = process.env.NODE_ENV === 'test';
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}`);
44
71
  }
45
- services_1.ApiConfigService.rootPath = process.env.ROOT_PATH;
72
+ const { envFilePath, rootPath, baseEnvFilePath } = findValidRootPath();
73
+ services_1.ApiConfigService.rootPath = rootPath;
46
74
  const modules = [
47
75
  setup_1.SentryModule.forRoot(),
48
76
  config_1.ConfigModule.forRoot({
49
77
  isGlobal: true,
50
78
  cache: true,
51
79
  expandVariables: false,
52
- envFilePath: [process.env.ENV_FILE_PATH, process.env.BASE_ENV_FILE_PATH],
80
+ envFilePath: [envFilePath, baseEnvFilePath],
53
81
  }),
54
82
  nestjs_cls_1.ClsModule.forRoot({
55
83
  global: true,