@nest-omni/core 2.0.1-9 → 3.1.1-10

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.
Files changed (41) hide show
  1. package/common/dto/page-options.dto.d.ts +1 -1
  2. package/common/index.d.ts +0 -1
  3. package/common/index.js +0 -1
  4. package/decorators/controller.decorator.d.ts +1 -1
  5. package/decorators/property.decorators.js +1 -1
  6. package/decorators/timestamp-column.decorator.d.ts +1 -1
  7. package/decorators/user_auth.decorator.d.ts +1 -1
  8. package/health-checker/health-checker.controller.d.ts +2 -4
  9. package/health-checker/health-checker.controller.js +2 -5
  10. package/health-checker/health-checker.module.js +2 -3
  11. package/health-checker/index.d.ts +2 -0
  12. package/health-checker/index.js +18 -0
  13. package/helpers/date.helper.js +10 -10
  14. package/index.d.ts +4 -0
  15. package/index.js +4 -0
  16. package/package.json +142 -46
  17. package/setup/bootstrap.setup.js +37 -87
  18. package/setup/index.d.ts +5 -0
  19. package/setup/index.js +5 -0
  20. package/setup/mode.setup.d.ts +12 -0
  21. package/setup/mode.setup.js +60 -0
  22. package/setup/redis.lock.decorator.d.ts +5 -0
  23. package/setup/redis.lock.decorator.js +60 -0
  24. package/setup/redis.lock.service.d.ts +56 -0
  25. package/setup/redis.lock.service.js +338 -0
  26. package/setup/schedule.decorator.d.ts +21 -0
  27. package/setup/schedule.decorator.js +127 -0
  28. package/setup/worker.decorator.d.ts +14 -0
  29. package/setup/worker.decorator.js +130 -0
  30. package/shared/serviceRegistryModule.js +17 -19
  31. package/shared/services/api-config.service.d.ts +9 -8
  32. package/shared/services/api-config.service.js +55 -46
  33. package/validator-json/default.js +9 -1
  34. package/validators/is-exists.validator.js +0 -2
  35. package/validators/is-unique.validator.js +0 -2
  36. package/validators/skip-empty.validator.d.ts +1 -1
  37. package/common/abstract-client.service.d.ts +0 -16
  38. package/common/abstract-client.service.js +0 -35
  39. package/health-checker/health-indicators/service.indicator.d.ts +0 -8
  40. package/health-checker/health-indicators/service.indicator.js +0 -66
  41. package/tsconfig.tsbuildinfo +0 -1
@@ -3,6 +3,6 @@ export declare class PageOptionsDto {
3
3
  readonly order: Order;
4
4
  readonly page: number;
5
5
  readonly pageSize: number;
6
- get skip(): number;
7
6
  readonly q?: string;
7
+ get skip(): number;
8
8
  }
package/common/index.d.ts CHANGED
@@ -1,5 +1,4 @@
1
1
  export * from './abstract.entity';
2
- export * from './abstract-client.service';
3
2
  export * from './utils';
4
3
  export * from './dto';
5
4
  export * from './types';
package/common/index.js CHANGED
@@ -15,7 +15,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./abstract.entity"), exports);
18
- __exportStar(require("./abstract-client.service"), exports);
19
18
  __exportStar(require("./utils"), exports);
20
19
  __exportStar(require("./dto"), exports);
21
20
  __exportStar(require("./types"), exports);
@@ -1 +1 @@
1
- export declare function Controller(field: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
1
+ export declare function Controller(field: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -24,7 +24,7 @@ function ApiUUIDPropertyOptional(options = {}) {
24
24
  function ApiEnumProperty(getEnum, options = {}) {
25
25
  const enumValue = getEnum();
26
26
  options.description = (0, field_decorators_1.getEnumDescription)(enumValue);
27
- return (0, swagger_1.ApiProperty)(Object.assign({ type: 'enum', enum: enumValue, enumName: (0, utils_1.getVariableName)(getEnum) }, options));
27
+ return (0, swagger_1.ApiProperty)(Object.assign({ enum: enumValue, enumName: (0, utils_1.getVariableName)(getEnum) }, options));
28
28
  }
29
29
  function ApiEnumPropertyOptional(getEnum, options = {}) {
30
30
  return ApiEnumProperty(getEnum, Object.assign({ required: false }, options));
@@ -1 +1 @@
1
- export declare function TimestampColumn(name: string, description?: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
1
+ export declare function TimestampColumn(name: string, description?: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1 +1 @@
1
- export declare function UserFilter(field: string): <TFunction extends Function, Y>(target: object | TFunction, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
1
+ export declare function UserFilter(field: string): <TFunction extends Function, Y>(target: TFunction | object, propertyKey?: string | symbol, descriptor?: TypedPropertyDescriptor<Y>) => void;
@@ -1,15 +1,13 @@
1
1
  import type { HealthCheckResult } from '@nestjs/terminus';
2
2
  import { HealthCheckService, TypeOrmHealthIndicator } from '@nestjs/terminus';
3
- import { ServiceHealthIndicator } from './health-indicators/service.indicator';
4
- import { RedisHealthIndicator } from '@mvmdev/nestjs-redis-health';
3
+ import { RedisHealthIndicator } from '@songkeys/nestjs-redis-health';
5
4
  import { ApiConfigService } from '../shared/services';
6
5
  export declare class HealthCheckerController {
7
6
  private configService;
8
7
  private healthCheckService;
9
8
  private ormIndicator;
10
- private serviceIndicator;
11
9
  private redisIndicator;
12
10
  private readonly redis;
13
- constructor(configService: ApiConfigService, healthCheckService: HealthCheckService, ormIndicator: TypeOrmHealthIndicator, serviceIndicator: ServiceHealthIndicator, redisIndicator: RedisHealthIndicator);
11
+ constructor(configService: ApiConfigService, healthCheckService: HealthCheckService, ormIndicator: TypeOrmHealthIndicator, redisIndicator: RedisHealthIndicator);
14
12
  check(): Promise<HealthCheckResult>;
15
13
  }
@@ -22,16 +22,14 @@ exports.HealthCheckerController = void 0;
22
22
  const ioredis_1 = require("ioredis");
23
23
  const common_1 = require("@nestjs/common");
24
24
  const terminus_1 = require("@nestjs/terminus");
25
- const service_indicator_1 = require("./health-indicators/service.indicator");
26
25
  const swagger_1 = require("@nestjs/swagger");
27
- const nestjs_redis_health_1 = require("@mvmdev/nestjs-redis-health");
26
+ const nestjs_redis_health_1 = require("@songkeys/nestjs-redis-health");
28
27
  const services_1 = require("../shared/services");
29
28
  let HealthCheckerController = class HealthCheckerController {
30
- constructor(configService, healthCheckService, ormIndicator, serviceIndicator, redisIndicator) {
29
+ constructor(configService, healthCheckService, ormIndicator, redisIndicator) {
31
30
  this.configService = configService;
32
31
  this.healthCheckService = healthCheckService;
33
32
  this.ormIndicator = ormIndicator;
34
- this.serviceIndicator = serviceIndicator;
35
33
  this.redisIndicator = redisIndicator;
36
34
  if (this.configService.isRedisEnabled) {
37
35
  this.redis = new ioredis_1.default(this.configService.ioRedisConfig);
@@ -67,6 +65,5 @@ exports.HealthCheckerController = HealthCheckerController = __decorate([
67
65
  __metadata("design:paramtypes", [services_1.ApiConfigService,
68
66
  terminus_1.HealthCheckService,
69
67
  terminus_1.TypeOrmHealthIndicator,
70
- service_indicator_1.ServiceHealthIndicator,
71
68
  nestjs_redis_health_1.RedisHealthIndicator])
72
69
  ], HealthCheckerController);
@@ -9,9 +9,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
9
9
  exports.HealthCheckerModule = void 0;
10
10
  const common_1 = require("@nestjs/common");
11
11
  const terminus_1 = require("@nestjs/terminus");
12
- const nestjs_redis_health_1 = require("@mvmdev/nestjs-redis-health");
12
+ const nestjs_redis_health_1 = require("@songkeys/nestjs-redis-health");
13
13
  const health_checker_controller_1 = require("./health-checker.controller");
14
- const service_indicator_1 = require("./health-indicators/service.indicator");
15
14
  const services_1 = require("../shared/services");
16
15
  let HealthCheckerModule = class HealthCheckerModule {
17
16
  };
@@ -20,6 +19,6 @@ exports.HealthCheckerModule = HealthCheckerModule = __decorate([
20
19
  (0, common_1.Module)({
21
20
  imports: [terminus_1.TerminusModule, nestjs_redis_health_1.RedisHealthModule],
22
21
  controllers: [health_checker_controller_1.HealthCheckerController],
23
- providers: [services_1.ApiConfigService, service_indicator_1.ServiceHealthIndicator],
22
+ providers: [services_1.ApiConfigService],
24
23
  })
25
24
  ], HealthCheckerModule);
@@ -0,0 +1,2 @@
1
+ export * from './health-checker.controller';
2
+ export * from './health-checker.module';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./health-checker.controller"), exports);
18
+ __exportStar(require("./health-checker.module"), exports);
@@ -6,40 +6,40 @@ exports.getTodayTimeStamp = getTodayTimeStamp;
6
6
  exports.unixtimestampToDate = unixtimestampToDate;
7
7
  exports.formatDateTime = formatDateTime;
8
8
  exports.timestampColumn = timestampColumn;
9
- const moment = require("moment");
10
- const _ = require("lodash");
9
+ const moment_1 = require("moment");
10
+ const lodash_1 = require("lodash");
11
11
  function timestamp(value) {
12
12
  if (!value) {
13
- value = moment.now();
13
+ value = moment_1.default.now();
14
14
  }
15
15
  return Math.round(value / 1000);
16
16
  }
17
17
  function strToTimeStamp(str) {
18
- if (_.isEmpty(str)) {
18
+ if (lodash_1.default.isEmpty(str)) {
19
19
  return 0;
20
20
  }
21
- return moment(str).unix();
21
+ return (0, moment_1.default)(str).unix();
22
22
  }
23
23
  function getTodayTimeStamp() {
24
- const startTime = strToTimeStamp(moment().format('YYYY-MM-DD 00:00:00'));
25
- const endTime = strToTimeStamp(moment().format('YYYY-MM-DD 23:59:59'));
24
+ const startTime = strToTimeStamp((0, moment_1.default)().format('YYYY-MM-DD 00:00:00'));
25
+ const endTime = strToTimeStamp((0, moment_1.default)().format('YYYY-MM-DD 23:59:59'));
26
26
  return {
27
27
  startTime,
28
28
  endTime,
29
29
  };
30
30
  }
31
31
  function unixtimestampToDate(value) {
32
- return moment(value * 1000).toDate();
32
+ return (0, moment_1.default)(value * 1000).toDate();
33
33
  }
34
34
  function formatDateTime(value, format = 'YYYY-MM-DD HH:mm:ss', holder = '') {
35
35
  if (value === 'now') {
36
- return moment().format(format);
36
+ return (0, moment_1.default)().format(format);
37
37
  }
38
38
  if (typeof value === 'string') {
39
39
  return value;
40
40
  }
41
41
  if (value > 0) {
42
- return moment(value * 1000).format(format);
42
+ return (0, moment_1.default)(value * 1000).format(format);
43
43
  }
44
44
  return holder;
45
45
  }
package/index.d.ts CHANGED
@@ -9,3 +9,7 @@ export * from './middlewares';
9
9
  export * from './validators';
10
10
  export * from './common';
11
11
  export * from './validator-json';
12
+ export * from './helpers';
13
+ export * from './providers';
14
+ export * from './setup';
15
+ export * from './health-checker';
package/index.js CHANGED
@@ -25,3 +25,7 @@ __exportStar(require("./middlewares"), exports);
25
25
  __exportStar(require("./validators"), exports);
26
26
  __exportStar(require("./common"), exports);
27
27
  __exportStar(require("./validator-json"), exports);
28
+ __exportStar(require("./helpers"), exports);
29
+ __exportStar(require("./providers"), exports);
30
+ __exportStar(require("./setup"), exports);
31
+ __exportStar(require("./health-checker"), exports);
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@nest-omni/core",
3
- "version": "2.0.1-9",
4
- "description": "framework",
3
+ "version": "3.1.1-10",
4
+ "description": "A comprehensive NestJS framework for building enterprise-grade applications with best practices",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
7
7
  "scripts": {
@@ -14,60 +14,156 @@
14
14
  "i18n": "i18n",
15
15
  "gen": "gen"
16
16
  },
17
+ "keywords": [
18
+ "nestjs",
19
+ "framework",
20
+ "typescript",
21
+ "decorators",
22
+ "validation",
23
+ "interceptors",
24
+ "filters",
25
+ "middleware",
26
+ "enterprise",
27
+ "omni",
28
+ "sentry",
29
+ "health-check",
30
+ "redis-lock",
31
+ "pm2"
32
+ ],
17
33
  "author": "Jinpy",
18
34
  "license": "Apache-2.0",
35
+ "engines": {
36
+ "node": ">=18.0.0",
37
+ "npm": ">=9.0.0"
38
+ },
19
39
  "devDependencies": {
20
- "typescript": "^5.4.5",
21
- "@types/compression": "^1.8.1"
40
+ "@types/compression": "^1.8.1",
41
+ "@types/express": "^5.0.3",
42
+ "@types/express-session": "^1.18.2",
43
+ "@types/lodash": "^4.17.20",
44
+ "@types/node": "^24.9.1",
45
+ "@types/sprintf-js": "^1.1.4",
46
+ "@types/uuid": "^10.0.0",
47
+ "typescript": "^5.9.3"
48
+ },
49
+ "dependencies": {
50
+ "@nestjs-cls/transactional": "^3.1.0",
51
+ "@nestjs-cls/transactional-adapter-typeorm": "^1.3.0",
52
+ "@sentry/nestjs": "^10.21.0",
53
+ "@sentry/profiling-node": "^10.21.0",
54
+ "axios": "^1.12.2",
55
+ "axios-retry": "^4.5.0",
56
+ "class-transformer": "^0.5.1",
57
+ "class-validator": "^0.14.2",
58
+ "compression": "^1.8.1",
59
+ "hygen": "^6.2.11",
60
+ "libphonenumber-js": "^1.12.24",
61
+ "lodash": "^4.17.21",
62
+ "moment": "^2.30.1",
63
+ "reflect-metadata": "^0.2.2",
64
+ "rxjs": "^7.8.2",
65
+ "sprintf-js": "^1.1.3",
66
+ "uuid": "^13.0.0"
22
67
  },
23
68
  "peerDependencies": {
24
69
  "@dataui/crud": "^5.3.0",
25
70
  "@dataui/crud-typeorm": "^5.3.0",
26
- "@mvmdev/nestjs-redis-health": "^10.0.1",
27
- "@nestjs/bull": "^10.0.1",
28
- "@nestjs/cache-manager": "^2.1.0",
29
- "@nestjs/common": "10.2.5",
71
+ "@keyv/redis": "^5.1.3",
72
+ "@songkeys/nestjs-redis": "^11.0.0",
73
+ "@songkeys/nestjs-redis-health": "^11.0.0",
74
+ "@nestjs/bull": "^11.0.0",
75
+ "@nestjs/cache-manager": "^3.0.0",
76
+ "@nestjs/common": "^11.0.0",
30
77
  "@nestjs/config": "^4.0.0",
31
- "@nestjs/core": "10.2.5",
32
- "@nestjs/microservices": "^10.2.5",
33
- "@nestjs/platform-express": "^10.2.5",
34
- "@nestjs/schedule": "^3.0.3",
35
- "@nestjs/swagger": "^7.1.11",
36
- "@nestjs/terminus": "^10.1.1",
37
- "@nestjs/typeorm": "^10.0.0",
38
- "axios": "^1.5.0",
39
- "axios-retry": "^3.7.0",
40
- "bcrypt": "5.1.0",
41
- "bull": "^4.11.3",
42
- "cache-manager-ioredis-yet": "^1.2.2",
43
- "class-transformer": "~0.5.1",
44
- "class-validator": "~0.14.0",
45
- "connect-redis": "^7.1.0",
46
- "express": "^4.18.2",
47
- "express-session": "^1.17.3",
48
- "libphonenumber-js": "^1.10.44",
49
- "lodash": "^4.17.21",
50
- "mime-types": "^2.1.35",
51
- "moment": "^2.29.4",
52
- "mysql2": "^3.6.1",
53
- "nestjs-cls": "^4.3.0",
78
+ "@nestjs/core": "^11.0.0",
79
+ "@nestjs/platform-express": "^11.0.0",
80
+ "@nestjs/schedule": "^6.0.0",
81
+ "@nestjs/swagger": "^11.0.0",
82
+ "@nestjs/terminus": "^11.0.0",
83
+ "@nestjs/typeorm": "^11.0.0",
84
+ "bcrypt": "^6.0.0",
85
+ "bull": "^4.16.0",
86
+ "cache-manager": "^7.0.0",
87
+ "keyv": "^5.5.3",
88
+ "connect-redis": "^9.0.0",
89
+ "express": "^5.0.0",
90
+ "express-session": "^1.18.0",
91
+ "mime-types": "^3.0.0",
92
+ "mysql2": "^3.0.0",
93
+ "nestjs-cls": "^6.0.0",
54
94
  "nestjs-i18n": "^10.5.0",
55
- "nestjs-pino": "^3.4.0",
56
- "pino-http": "^8.5.0",
57
- "pino-pretty": "^10.2.0",
58
- "reflect-metadata": "^0.1.13",
59
- "rxjs": "^7.8.1",
95
+ "nestjs-pino": "^4.0.0",
96
+ "pino-http": "^11.0.0",
97
+ "pino-pretty": "^13.0.0",
60
98
  "source-map-support": "^0.5.21",
61
- "sprintf-js": "^1.1.3",
62
- "typeorm": "^0.3.17",
63
- "typeorm-transactional": "~0.4.1",
64
- "uuid": "^9.0.1"
99
+ "typeorm": "^0.3.20"
65
100
  },
66
- "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"
101
+ "peerDependenciesMeta": {
102
+ "@dataui/crud": {
103
+ "optional": false
104
+ },
105
+ "@dataui/crud-typeorm": {
106
+ "optional": false
107
+ },
108
+ "@keyv/redis": {
109
+ "optional": true
110
+ },
111
+ "@songkeys/nestjs-redis": {
112
+ "optional": true
113
+ },
114
+ "@songkeys/nestjs-redis-health": {
115
+ "optional": true
116
+ },
117
+ "@nestjs/bull": {
118
+ "optional": false
119
+ },
120
+ "@nestjs/cache-manager": {
121
+ "optional": false
122
+ },
123
+ "@nestjs/schedule": {
124
+ "optional": false
125
+ },
126
+ "@nestjs/swagger": {
127
+ "optional": true
128
+ },
129
+ "bcrypt": {
130
+ "optional": false
131
+ },
132
+ "bull": {
133
+ "optional": false
134
+ },
135
+ "cache-manager": {
136
+ "optional": false
137
+ },
138
+ "connect-redis": {
139
+ "optional": false
140
+ },
141
+ "express-session": {
142
+ "optional": false
143
+ },
144
+ "keyv": {
145
+ "optional": false
146
+ },
147
+ "mysql2": {
148
+ "optional": false
149
+ },
150
+ "nestjs-cls": {
151
+ "optional": false
152
+ },
153
+ "nestjs-i18n": {
154
+ "optional": false
155
+ },
156
+ "nestjs-pino": {
157
+ "optional": false
158
+ },
159
+ "pino-http": {
160
+ "optional": false
161
+ },
162
+ "pino-pretty": {
163
+ "optional": false
164
+ },
165
+ "typeorm": {
166
+ "optional": false
167
+ }
72
168
  }
73
169
  }
@@ -16,6 +16,7 @@ const dotenv = require("dotenv");
16
16
  const fs_1 = require("fs");
17
17
  const path_1 = require("path");
18
18
  const process = require("process");
19
+ const mode_setup_1 = require("./mode.setup");
19
20
  function findValidRootPath() {
20
21
  const getAppRootPath = () => {
21
22
  if (require.main && require.main.filename) {
@@ -69,24 +70,24 @@ Sentry.init({
69
70
  dsn: process.env.SENTRY_DSN || '',
70
71
  release: process.env.API_VERSION || '',
71
72
  environment: process.env.NODE_ENV || 'unkown',
72
- debug: process.env.NODE_ENV === 'dev',
73
- tracesSampleRate: 1.0,
74
- profileSessionSampleRate: 1.0,
73
+ debug: false,
74
+ sampleRate: 1.0,
75
+ tracesSampleRate: 0.01,
76
+ profileSessionSampleRate: 0.01,
75
77
  profileLifecycle: 'trace',
76
78
  sendDefaultPii: true,
77
79
  integrations: [profiling_node_1.nodeProfilingIntegration],
78
80
  });
79
81
  const crud_1 = require("@dataui/crud");
80
82
  const core_1 = require("@nestjs/core");
81
- const typeorm_transactional_1 = require("typeorm-transactional");
82
83
  const nestjs_pino_1 = require("nestjs-pino");
83
84
  const session = require("express-session");
84
85
  const bodyParse = require("body-parser");
86
+ const compression = require("compression");
85
87
  const __1 = require("../");
86
88
  const common_1 = require("@nestjs/common");
87
89
  const nestjs_i18n_1 = require("nestjs-i18n");
88
90
  const nestjs_cls_1 = require("nestjs-cls");
89
- const compression = require("compression");
90
91
  const class_validator_1 = require("class-validator");
91
92
  const setup_1 = require("@sentry/nestjs/setup");
92
93
  crud_1.CrudConfigService.load({
@@ -116,79 +117,21 @@ crud_1.CrudConfigService.load({
116
117
  },
117
118
  },
118
119
  });
119
- const setupProcessHandlers = (app) => {
120
- const logger = app.get(nestjs_pino_1.Logger);
121
- process.on('uncaughtException', (error) => {
122
- logger.fatal({ error, stack: error.stack, pid: process.pid }, 'Uncaught Exception');
123
- process.exit(1);
124
- });
125
- process.on('unhandledRejection', (reason, promise) => {
126
- logger.error({
127
- reason: {
128
- message: reason.message,
129
- stack: reason.stack,
130
- name: reason.name,
131
- },
132
- promise,
133
- pid: process.pid,
134
- }, 'Unhandled Rejection');
135
- });
136
- process.on('exit', (code) => {
137
- logger.warn(`Process exiting with code ${code}`, {
138
- uptime: process.uptime(),
139
- memoryUsage: process.memoryUsage(),
140
- });
141
- });
142
- };
143
- const setupGracefulShutdown = (app) => {
144
- const logger = app.get(nestjs_pino_1.Logger);
145
- const shutdown = (signal) => __awaiter(void 0, void 0, void 0, function* () {
146
- var _a;
147
- try {
148
- logger.warn(`Received ${signal}, starting graceful shutdown...`, {
149
- uptime: process.uptime(),
150
- connections: (_a = app.getHttpServer()) === null || _a === void 0 ? void 0 : _a.address(),
151
- });
152
- yield Promise.race([
153
- app.close(),
154
- new Promise((_, reject) => setTimeout(() => reject(new Error('Shutdown timeout exceeded')), 15000)),
155
- ]);
156
- logger.log('Application successfully closed', {
157
- resourcesReleased: true,
158
- pid: process.pid,
159
- });
160
- process.exit(0);
161
- }
162
- catch (err) {
163
- logger.error('Graceful shutdown failed', {
164
- error: {
165
- message: err.message,
166
- stack: err.stack,
167
- name: err.name,
168
- },
169
- critical: true,
170
- pid: process.pid,
171
- });
172
- process.exit(1);
173
- }
174
- });
175
- process.on('SIGQUIT', () => shutdown('SIGQUIT'));
176
- process.on('SIGHUP', () => shutdown('SIGHUP'));
177
- process.on('SIGTERM', () => shutdown('SIGTERM'));
178
- process.on('SIGINT', () => shutdown('SIGINT'));
179
- };
180
120
  function bootstrapSetup(AppModule, SetupSwagger) {
181
121
  return __awaiter(this, void 0, void 0, function* () {
182
- (0, typeorm_transactional_1.initializeTransactionalContext)();
122
+ const shouldStartHttp = (0, mode_setup_1.shouldStartHttpServer)();
183
123
  const app = yield core_1.NestFactory.create(AppModule, {
184
124
  bufferLogs: true,
125
+ autoFlushLogs: true,
185
126
  });
186
127
  (0, class_validator_1.useContainer)(app.select(AppModule), { fallbackOnErrors: true });
187
128
  const configService = app.select(__1.ServiceRegistryModule).get(__1.ApiConfigService);
188
129
  const logger = app.get(nestjs_pino_1.Logger);
189
- setupProcessHandlers(app);
130
+ app.useLogger(logger);
131
+ app.flushLogs();
132
+ logger.log(`Application Mode: ${(0, mode_setup_1.getModeDescription)()}`);
133
+ logger.log(`Environment: ${process.env.NODE_ENV || 'unknown'}`);
190
134
  app.enableShutdownHooks();
191
- setupGracefulShutdown(app);
192
135
  app.enableVersioning();
193
136
  app.enable('trust proxy');
194
137
  app.use(bodyParse.json({ limit: '50mb' }), new nestjs_cls_1.ClsMiddleware({}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)(), compression());
@@ -202,26 +145,33 @@ function bootstrapSetup(AppModule, SetupSwagger) {
202
145
  stopAtFirstError: true,
203
146
  validationError: { target: false, value: false },
204
147
  }));
205
- if (configService.documentationEnabled && SetupSwagger) {
206
- SetupSwagger(app, configService.documentationPath);
207
- logger.log(`Swagger docs available at ${configService.documentationPath}`);
208
- }
209
- if (configService.viewsEnabled) {
210
- app.setBaseViewsDir((0, path_1.join)(__1.ApiConfigService.rootPath, 'views'));
211
- app.setViewEngine('ejs');
212
- logger.log('View engine initialized');
213
- }
214
- if (configService.sessionEnabled) {
215
- app.use(session(configService.sessionConfig));
216
- logger.log('Session middleware enabled');
148
+ if (shouldStartHttp) {
149
+ if (configService.documentationEnabled && SetupSwagger) {
150
+ SetupSwagger(app, configService.documentationPath);
151
+ logger.log(`Swagger docs available at ${configService.documentationPath}`);
152
+ }
153
+ if (configService.viewsEnabled) {
154
+ app.setBaseViewsDir((0, path_1.join)(__1.ApiConfigService.rootPath, 'views'));
155
+ app.setViewEngine('ejs');
156
+ logger.log('View engine initialized');
157
+ }
158
+ if (configService.sessionEnabled) {
159
+ app.use(session(configService.sessionConfig));
160
+ logger.log('Session middleware enabled');
161
+ }
162
+ if (configService.corsEnabled) {
163
+ app.enableCors(configService.corsConfig);
164
+ logger.log('CORS configuration applied');
165
+ }
166
+ const port = configService.appConfig.port;
167
+ yield app.listen(port);
168
+ logger.log(`HTTP Server running on ${yield app.getUrl()}`);
217
169
  }
218
- if (configService.corsEnabled) {
219
- app.enableCors(configService.corsConfig);
220
- logger.log('CORS configuration applied');
170
+ else {
171
+ logger.log('Running in Worker-only mode - HTTP server not started');
172
+ logger.log('Application is ready to process background tasks');
173
+ yield app.init();
221
174
  }
222
- const port = configService.appConfig.port;
223
- yield app.listen(port);
224
- logger.log(`Server running on ${yield app.getUrl()}`);
225
175
  return app;
226
176
  });
227
177
  }
package/setup/index.d.ts CHANGED
@@ -1 +1,6 @@
1
1
  export * from './bootstrap.setup';
2
+ export * from './mode.setup';
3
+ export * from './worker.decorator';
4
+ export * from './schedule.decorator';
5
+ export * from './redis.lock.service';
6
+ export * from './redis.lock.decorator';
package/setup/index.js CHANGED
@@ -15,3 +15,8 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./bootstrap.setup"), exports);
18
+ __exportStar(require("./mode.setup"), exports);
19
+ __exportStar(require("./worker.decorator"), exports);
20
+ __exportStar(require("./schedule.decorator"), exports);
21
+ __exportStar(require("./redis.lock.service"), exports);
22
+ __exportStar(require("./redis.lock.decorator"), exports);
@@ -0,0 +1,12 @@
1
+ export declare enum ApplicationMode {
2
+ HTTP = "http",
3
+ WORKER = "worker",
4
+ HYBRID = "hybrid"
5
+ }
6
+ export declare function getApplicationMode(): ApplicationMode;
7
+ export declare function shouldProcessQueues(): boolean;
8
+ export declare function shouldStartHttpServer(): boolean;
9
+ export declare function isHttpMode(): boolean;
10
+ export declare function isWorkerMode(): boolean;
11
+ export declare function isHybridMode(): boolean;
12
+ export declare function getModeDescription(): string;