@nest-omni/core 1.0.17 → 1.0.20
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/common → common}/abstract.entity.d.ts +1 -1
- package/{dist/common → common}/abstract.entity.js +4 -4
- package/{dist/common → common}/dto/abstract.dto.d.ts +3 -3
- package/{dist/health-checker → health-checker}/health-checker.controller.d.ts +1 -1
- package/{dist/health-checker → health-checker}/health-checker.controller.js +1 -1
- package/{dist/health-checker → health-checker}/health-checker.module.js +1 -1
- package/package.json +4 -10
- package/{dist/setup → setup}/bootstrap.setup.js +5 -2
- package/{dist/shared → shared}/serviceRegistryModule.js +25 -14
- package/{dist/shared → shared}/services/api-config.service.d.ts +1 -1
- package/{dist/shared → shared}/services/api-config.service.js +4 -1
- package/tsconfig.tsbuildinfo +1 -0
- package/README.md +0 -16
- package/dist/tsconfig.tsbuildinfo +0 -1
- /package/{dist/common → common}/abstract-client.service.d.ts +0 -0
- /package/{dist/common → common}/abstract-client.service.js +0 -0
- /package/{dist/common → common}/boilerplate.polyfill.d.ts +0 -0
- /package/{dist/common → common}/boilerplate.polyfill.js +0 -0
- /package/{dist/common → common}/dto/abstract.dto.js +0 -0
- /package/{dist/common → common}/dto/bulk-id.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/bulk-id.dto.js +0 -0
- /package/{dist/common → common}/dto/create-translation.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/create-translation.dto.js +0 -0
- /package/{dist/common → common}/dto/index.d.ts +0 -0
- /package/{dist/common → common}/dto/index.js +0 -0
- /package/{dist/common → common}/dto/page-meta.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page-meta.dto.js +0 -0
- /package/{dist/common → common}/dto/page-options.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page-options.dto.js +0 -0
- /package/{dist/common → common}/dto/page.dto.d.ts +0 -0
- /package/{dist/common → common}/dto/page.dto.js +0 -0
- /package/{dist/common → common}/index.d.ts +0 -0
- /package/{dist/common → common}/index.js +0 -0
- /package/{dist/common → common}/snake-naming.strategy.d.ts +0 -0
- /package/{dist/common → common}/snake-naming.strategy.js +0 -0
- /package/{dist/common → common}/types.d.ts +0 -0
- /package/{dist/common → common}/types.js +0 -0
- /package/{dist/common → common}/utils.d.ts +0 -0
- /package/{dist/common → common}/utils.js +0 -0
- /package/{dist/constants → constants}/index.d.ts +0 -0
- /package/{dist/constants → constants}/index.js +0 -0
- /package/{dist/constants → constants}/language-code.d.ts +0 -0
- /package/{dist/constants → constants}/language-code.js +0 -0
- /package/{dist/constants → constants}/order.d.ts +0 -0
- /package/{dist/constants → constants}/order.js +0 -0
- /package/{dist/decorators → decorators}/api-page-ok-response.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/api-page-ok-response.decorator.js +0 -0
- /package/{dist/decorators → decorators}/auth-user.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/auth-user.decorator.js +0 -0
- /package/{dist/decorators → decorators}/controller.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/controller.decorator.js +0 -0
- /package/{dist/decorators → decorators}/field.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/field.decorators.js +0 -0
- /package/{dist/decorators → decorators}/http.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/http.decorators.js +0 -0
- /package/{dist/decorators → decorators}/index.d.ts +0 -0
- /package/{dist/decorators → decorators}/index.js +0 -0
- /package/{dist/decorators → decorators}/omni-auth.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/omni-auth.decorator.js +0 -0
- /package/{dist/decorators → decorators}/operation.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/operation.decorator.js +0 -0
- /package/{dist/decorators → decorators}/property.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/property.decorators.js +0 -0
- /package/{dist/decorators → decorators}/public-route.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/public-route.decorator.js +0 -0
- /package/{dist/decorators → decorators}/swagger.schema.d.ts +0 -0
- /package/{dist/decorators → decorators}/swagger.schema.js +0 -0
- /package/{dist/decorators → decorators}/timestamp-column.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/timestamp-column.decorator.js +0 -0
- /package/{dist/decorators → decorators}/transform.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/transform.decorators.js +0 -0
- /package/{dist/decorators → decorators}/translate.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/translate.decorator.js +0 -0
- /package/{dist/decorators → decorators}/use-dto.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/use-dto.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user-check.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user-check.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user.decorator.js +0 -0
- /package/{dist/decorators → decorators}/user_auth.decorator.d.ts +0 -0
- /package/{dist/decorators → decorators}/user_auth.decorator.js +0 -0
- /package/{dist/decorators → decorators}/validator.decorators.d.ts +0 -0
- /package/{dist/decorators → decorators}/validator.decorators.js +0 -0
- /package/{dist/exceptions → exceptions}/file-not-image.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/file-not-image.exception.js +0 -0
- /package/{dist/exceptions → exceptions}/index.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/index.js +0 -0
- /package/{dist/exceptions → exceptions}/page-type.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/page-type.exception.js +0 -0
- /package/{dist/exceptions → exceptions}/user-not-found.exception.d.ts +0 -0
- /package/{dist/exceptions → exceptions}/user-not-found.exception.js +0 -0
- /package/{dist/filters → filters}/bad-request.filter.d.ts +0 -0
- /package/{dist/filters → filters}/bad-request.filter.js +0 -0
- /package/{dist/filters → filters}/constraint-errors.d.ts +0 -0
- /package/{dist/filters → filters}/constraint-errors.js +0 -0
- /package/{dist/filters → filters}/index.d.ts +0 -0
- /package/{dist/filters → filters}/index.js +0 -0
- /package/{dist/filters → filters}/query-failed.filter.d.ts +0 -0
- /package/{dist/filters → filters}/query-failed.filter.js +0 -0
- /package/{dist/health-checker → health-checker}/health-checker.module.d.ts +0 -0
- /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.d.ts +0 -0
- /package/{dist/health-checker → health-checker}/health-indicators/service.indicator.js +0 -0
- /package/{dist/helpers → helpers}/common.helper.d.ts +0 -0
- /package/{dist/helpers → helpers}/common.helper.js +0 -0
- /package/{dist/helpers → helpers}/date.helper.d.ts +0 -0
- /package/{dist/helpers → helpers}/date.helper.js +0 -0
- /package/{dist/helpers → helpers}/index.d.ts +0 -0
- /package/{dist/helpers → helpers}/index.js +0 -0
- /package/{dist/i18n → i18n}/en_US/validation.json +0 -0
- /package/{dist/i18n → i18n}/zh_CN/validation.json +0 -0
- /package/{dist/index.d.ts → index.d.ts} +0 -0
- /package/{dist/index.js → index.js} +0 -0
- /package/{dist/interceptors → interceptors}/auth-user.interceptor.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/auth-user.interceptor.js +0 -0
- /package/{dist/interceptors → interceptors}/index.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/index.js +0 -0
- /package/{dist/interceptors → interceptors}/language-interceptor.service.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/language-interceptor.service.js +0 -0
- /package/{dist/interceptors → interceptors}/translation-interceptor.service.d.ts +0 -0
- /package/{dist/interceptors → interceptors}/translation-interceptor.service.js +0 -0
- /package/{dist/interfaces → interfaces}/IApiFile.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/IApiFile.js +0 -0
- /package/{dist/interfaces → interfaces}/IFile.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/IFile.js +0 -0
- /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/ITranslationDecoratorInterface.js +0 -0
- /package/{dist/interfaces → interfaces}/index.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/index.js +0 -0
- /package/{dist/interfaces → interfaces}/response.d.ts +0 -0
- /package/{dist/interfaces → interfaces}/response.js +0 -0
- /package/{dist/middlewares → middlewares}/index.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/index.js +0 -0
- /package/{dist/middlewares → middlewares}/omni-auth.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/omni-auth.middleware.js +0 -0
- /package/{dist/middlewares → middlewares}/powerby.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/powerby.middleware.js +0 -0
- /package/{dist/middlewares → middlewares}/request-id.middleware.d.ts +0 -0
- /package/{dist/middlewares → middlewares}/request-id.middleware.js +0 -0
- /package/{dist/providers → providers}/context.provider.d.ts +0 -0
- /package/{dist/providers → providers}/context.provider.js +0 -0
- /package/{dist/providers → providers}/generator.provider.d.ts +0 -0
- /package/{dist/providers → providers}/generator.provider.js +0 -0
- /package/{dist/providers → providers}/index.d.ts +0 -0
- /package/{dist/providers → providers}/index.js +0 -0
- /package/{dist/setup → setup}/bootstrap.setup.d.ts +0 -0
- /package/{dist/setup → setup}/index.d.ts +0 -0
- /package/{dist/setup → setup}/index.js +0 -0
- /package/{dist/shared → shared}/index.d.ts +0 -0
- /package/{dist/shared → shared}/index.js +0 -0
- /package/{dist/shared → shared}/serviceRegistryModule.d.ts +0 -0
- /package/{dist/shared → shared}/services/aws-s3.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/aws-s3.service.js +0 -0
- /package/{dist/shared → shared}/services/generator.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/generator.service.js +0 -0
- /package/{dist/shared → shared}/services/index.d.ts +0 -0
- /package/{dist/shared → shared}/services/index.js +0 -0
- /package/{dist/shared → shared}/services/translation.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/translation.service.js +0 -0
- /package/{dist/shared → shared}/services/validator.service.d.ts +0 -0
- /package/{dist/shared → shared}/services/validator.service.js +0 -0
- /package/{dist/validator-json → validator-json}/decorators.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/decorators.js +0 -0
- /package/{dist/validator-json → validator-json}/default.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/default.js +0 -0
- /package/{dist/validator-json → validator-json}/defaultConverters.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/defaultConverters.js +0 -0
- /package/{dist/validator-json → validator-json}/index.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/index.js +0 -0
- /package/{dist/validator-json → validator-json}/options.d.ts +0 -0
- /package/{dist/validator-json → validator-json}/options.js +0 -0
- /package/{dist/validators → validators}/file-mimetype.validator.d.ts +0 -0
- /package/{dist/validators → validators}/file-mimetype.validator.js +0 -0
- /package/{dist/validators → validators}/index.d.ts +0 -0
- /package/{dist/validators → validators}/index.js +0 -0
- /package/{dist/validators → validators}/is-exists.validator.d.ts +0 -0
- /package/{dist/validators → validators}/is-exists.validator.js +0 -0
- /package/{dist/validators → validators}/is-unique.validator.d.ts +0 -0
- /package/{dist/validators → validators}/is-unique.validator.js +0 -0
- /package/{dist/validators → validators}/phone-country-code.validator.d.ts +0 -0
- /package/{dist/validators → validators}/phone-country-code.validator.js +0 -0
- /package/{dist/validators → validators}/same-as.validator.d.ts +0 -0
- /package/{dist/validators → validators}/same-as.validator.js +0 -0
- /package/{dist/validators → validators}/skip-empty.validator.d.ts +0 -0
- /package/{dist/validators → validators}/skip-empty.validator.js +0 -0
|
@@ -12,6 +12,6 @@ export declare class AbstractEntity<DTO extends AbstractDto = AbstractDto, O = n
|
|
|
12
12
|
export declare class AbstractTranslationEntity<DTO extends AbstractTranslationDto = AbstractTranslationDto, O = never> extends AbstractEntity<DTO, O> {
|
|
13
13
|
languageCode: LanguageCode;
|
|
14
14
|
}
|
|
15
|
-
export declare class
|
|
15
|
+
export declare class AbstractUuidPrimaryEntity<DTO extends AbstractDto = AbstractDto, O = never> extends AbstractBaseEntity<DTO, O> {
|
|
16
16
|
id: string;
|
|
17
17
|
}
|
|
@@ -9,7 +9,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
9
9
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.
|
|
12
|
+
exports.AbstractUuidPrimaryEntity = exports.AbstractTranslationEntity = exports.AbstractEntity = exports.AbstractBaseEntity = void 0;
|
|
13
13
|
const typeorm_1 = require("typeorm");
|
|
14
14
|
const decorators_1 = require("../decorators");
|
|
15
15
|
const constants_1 = require("../constants");
|
|
@@ -50,9 +50,9 @@ __decorate([
|
|
|
50
50
|
(0, typeorm_1.Column)({ type: 'enum', enum: constants_1.LanguageCode }),
|
|
51
51
|
__metadata("design:type", String)
|
|
52
52
|
], AbstractTranslationEntity.prototype, "languageCode", void 0);
|
|
53
|
-
class
|
|
53
|
+
class AbstractUuidPrimaryEntity extends AbstractBaseEntity {
|
|
54
54
|
}
|
|
55
|
-
exports.
|
|
55
|
+
exports.AbstractUuidPrimaryEntity = AbstractUuidPrimaryEntity;
|
|
56
56
|
__decorate([
|
|
57
57
|
(0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
|
|
58
58
|
(0, decorators_1.StringFieldOptional)({
|
|
@@ -61,4 +61,4 @@ __decorate([
|
|
|
61
61
|
example: '23247899-c237-4ab1-9639-3322029d2e1c',
|
|
62
62
|
}),
|
|
63
63
|
__metadata("design:type", String)
|
|
64
|
-
],
|
|
64
|
+
], AbstractUuidPrimaryEntity.prototype, "id", void 0);
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { AbstractEntity,
|
|
1
|
+
import { AbstractEntity, AbstractUuidPrimaryEntity } from '../abstract.entity';
|
|
2
2
|
export declare class AbstractDto {
|
|
3
3
|
id: number | string;
|
|
4
4
|
createdAt: Date;
|
|
5
5
|
updatedAt: Date;
|
|
6
6
|
translations?: AbstractTranslationDto[];
|
|
7
|
-
constructor(entity: AbstractEntity |
|
|
7
|
+
constructor(entity: AbstractEntity | AbstractUuidPrimaryEntity, options?: {
|
|
8
8
|
excludeFields?: boolean;
|
|
9
9
|
});
|
|
10
10
|
}
|
|
11
11
|
export declare class AbstractTranslationDto extends AbstractDto {
|
|
12
|
-
constructor(entity: AbstractEntity |
|
|
12
|
+
constructor(entity: AbstractEntity | AbstractUuidPrimaryEntity);
|
|
13
13
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { HealthCheckResult } from '@nestjs/terminus';
|
|
2
2
|
import { HealthCheckService, TypeOrmHealthIndicator } from '@nestjs/terminus';
|
|
3
3
|
import { ServiceHealthIndicator } from './health-indicators/service.indicator';
|
|
4
|
-
import { RedisHealthIndicator } from '@
|
|
4
|
+
import { RedisHealthIndicator } from '@mvmdev/nestjs-redis-health';
|
|
5
5
|
import { ApiConfigService } from '../shared/services';
|
|
6
6
|
export declare class HealthCheckerController {
|
|
7
7
|
private configService;
|
|
@@ -24,7 +24,7 @@ const common_1 = require("@nestjs/common");
|
|
|
24
24
|
const terminus_1 = require("@nestjs/terminus");
|
|
25
25
|
const service_indicator_1 = require("./health-indicators/service.indicator");
|
|
26
26
|
const swagger_1 = require("@nestjs/swagger");
|
|
27
|
-
const nestjs_redis_health_1 = require("@
|
|
27
|
+
const nestjs_redis_health_1 = require("@mvmdev/nestjs-redis-health");
|
|
28
28
|
const services_1 = require("../shared/services");
|
|
29
29
|
let HealthCheckerController = class HealthCheckerController {
|
|
30
30
|
constructor(configService, healthCheckService, ormIndicator, serviceIndicator, redisIndicator) {
|
|
@@ -9,7 +9,7 @@ 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("@
|
|
12
|
+
const nestjs_redis_health_1 = require("@mvmdev/nestjs-redis-health");
|
|
13
13
|
const health_checker_controller_1 = require("./health-checker.controller");
|
|
14
14
|
const service_indicator_1 = require("./health-indicators/service.indicator");
|
|
15
15
|
const services_1 = require("../shared/services");
|
package/package.json
CHANGED
|
@@ -1,25 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@nest-omni/core",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.20",
|
|
4
4
|
"description": "framework",
|
|
5
|
-
"main": "
|
|
6
|
-
"types": "
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"types": "index.d.ts",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -p tsconfig.json",
|
|
9
9
|
"test": "jest --passWithNoTests",
|
|
10
|
-
"lint": "eslint 'src/**/*.ts' --fix"
|
|
11
|
-
"prepublish:npm": "npm run build",
|
|
12
|
-
"publish:npm": "npm publish --access public",
|
|
13
|
-
"prepare": "npm run build"
|
|
10
|
+
"lint": "eslint 'src/**/*.ts' --fix"
|
|
14
11
|
},
|
|
15
12
|
"author": "Jinpy",
|
|
16
13
|
"license": "Apache-2.0",
|
|
17
14
|
"devDependencies": {
|
|
18
15
|
"typescript": "^5.4.5"
|
|
19
16
|
},
|
|
20
|
-
"files": [
|
|
21
|
-
"dist"
|
|
22
|
-
],
|
|
23
17
|
"peerDependencies": {
|
|
24
18
|
"@dataui/crud": "^5.3.0",
|
|
25
19
|
"@dataui/crud-typeorm": "^5.3.0",
|
|
@@ -15,6 +15,7 @@ const typeorm_transactional_1 = require("typeorm-transactional");
|
|
|
15
15
|
const skywalking_backend_js_1 = require("skywalking-backend-js");
|
|
16
16
|
const nestjs_pino_1 = require("nestjs-pino");
|
|
17
17
|
const session = require("express-session");
|
|
18
|
+
const bodyParse = require("body-parser");
|
|
18
19
|
const path_1 = require("path");
|
|
19
20
|
const __1 = require("../");
|
|
20
21
|
const common_1 = require("@nestjs/common");
|
|
@@ -64,7 +65,9 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
64
65
|
app.enable('trust proxy');
|
|
65
66
|
const reflector = app.get(core_1.Reflector);
|
|
66
67
|
app.useGlobalFilters(new __1.HttpExceptionFilter(), new __1.QueryFailedFilter(reflector));
|
|
67
|
-
app.use(
|
|
68
|
+
app.use(bodyParse.json({
|
|
69
|
+
limit: '50mb',
|
|
70
|
+
}), new nestjs_cls_1.ClsMiddleware({}).use, (0, __1.RequestIdMiddleware)(), (0, __1.PowerByMiddleware)(), (0, __1.OmniAuthMiddleware)());
|
|
68
71
|
app.useStaticAssets('public', { prefix: '/' });
|
|
69
72
|
app.useGlobalInterceptors(new auth_user_interceptor_1.AuthUserInterceptor(), new __1.TranslationInterceptor(), new nestjs_pino_1.LoggerErrorInterceptor(), new nestjs_sentry_1.SentryInterceptor({
|
|
70
73
|
filters: [
|
|
@@ -94,7 +97,7 @@ function bootstrapSetup(AppModule, SetupSwagger) {
|
|
|
94
97
|
SetupSwagger(app, configService.documentationPath);
|
|
95
98
|
}
|
|
96
99
|
if (configService.viewsEnabled) {
|
|
97
|
-
app.setBaseViewsDir((0, path_1.join)(
|
|
100
|
+
app.setBaseViewsDir((0, path_1.join)(__1.ApiConfigService.rootPath, 'views'));
|
|
98
101
|
app.setViewEngine('ejs');
|
|
99
102
|
}
|
|
100
103
|
if (configService.sessionEnabled) {
|
|
@@ -35,16 +35,22 @@ const fs_1 = require("fs");
|
|
|
35
35
|
const providers = [
|
|
36
36
|
services_1.ApiConfigService,
|
|
37
37
|
services_1.ValidatorService,
|
|
38
|
-
services_1.AwsS3Service,
|
|
39
38
|
services_1.GeneratorService,
|
|
40
39
|
services_1.TranslationService,
|
|
41
40
|
];
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
41
|
+
function findValidRootPath() {
|
|
42
|
+
const possibleRootPaths = [process.cwd(), __dirname];
|
|
43
|
+
const envFile = `${process.env.NODE_ENV || ''}.env`;
|
|
44
|
+
for (const rootPath of possibleRootPaths) {
|
|
45
|
+
const envFilePath = path.join(rootPath, 'config', envFile);
|
|
46
|
+
if ((0, fs_1.existsSync)(envFilePath)) {
|
|
47
|
+
return { rootPath, envFilePath };
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
throw new Error('No valid .env file found in any root path');
|
|
47
51
|
}
|
|
52
|
+
const { envFilePath, rootPath } = findValidRootPath();
|
|
53
|
+
services_1.ApiConfigService.rootPath = rootPath;
|
|
48
54
|
const modules = [
|
|
49
55
|
config_1.ConfigModule.forRoot({
|
|
50
56
|
isGlobal: true,
|
|
@@ -61,19 +67,12 @@ const modules = [
|
|
|
61
67
|
inject: [services_1.ApiConfigService],
|
|
62
68
|
useFactory: (config) => config.pinoConfig,
|
|
63
69
|
}),
|
|
64
|
-
typeorm_2.TypeOrmModule.forRootAsync({
|
|
65
|
-
inject: [services_1.ApiConfigService],
|
|
66
|
-
useFactory: (config) => config.typeormConfig,
|
|
67
|
-
dataSourceFactory: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
68
|
-
return (0, typeorm_transactional_1.addTransactionalDataSource)(new typeorm_1.DataSource(options));
|
|
69
|
-
}),
|
|
70
|
-
}),
|
|
71
70
|
nestjs_i18n_1.I18nModule.forRootAsync({
|
|
72
71
|
inject: [services_1.ApiConfigService],
|
|
73
72
|
useFactory: (config) => ({
|
|
74
73
|
fallbackLanguage: config.fallbackLanguage,
|
|
75
74
|
loaderOptions: {
|
|
76
|
-
path: path.join(
|
|
75
|
+
path: path.join(services_1.ApiConfigService.rootPath, '/i18n/'),
|
|
77
76
|
watch: config.isDev,
|
|
78
77
|
},
|
|
79
78
|
logging: config.isDev,
|
|
@@ -82,6 +81,18 @@ const modules = [
|
|
|
82
81
|
}),
|
|
83
82
|
health_checker_module_1.HealthCheckerModule,
|
|
84
83
|
];
|
|
84
|
+
if (services_1.ApiConfigService.toBoolean(process.env.S3_ENABLED, false)) {
|
|
85
|
+
providers.push(services_1.AwsS3Service);
|
|
86
|
+
}
|
|
87
|
+
if (services_1.ApiConfigService.toBoolean(process.env.DB_ENABLED, true)) {
|
|
88
|
+
modules.push(typeorm_2.TypeOrmModule.forRootAsync({
|
|
89
|
+
inject: [services_1.ApiConfigService],
|
|
90
|
+
useFactory: (config) => config.typeormConfig,
|
|
91
|
+
dataSourceFactory: (options) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
return (0, typeorm_transactional_1.addTransactionalDataSource)(new typeorm_1.DataSource(options));
|
|
93
|
+
}),
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
85
96
|
if (services_1.ApiConfigService.toBoolean(process.env.BULL_ENABLED)) {
|
|
86
97
|
modules.push(bull_1.BullModule.forRootAsync({
|
|
87
98
|
inject: [services_1.ApiConfigService],
|
|
@@ -18,7 +18,7 @@ export declare class ApiConfigService {
|
|
|
18
18
|
get isTest(): boolean;
|
|
19
19
|
getNumber(key: string): number;
|
|
20
20
|
getBoolean(key: string): boolean;
|
|
21
|
-
static toBoolean(value: string): boolean;
|
|
21
|
+
static toBoolean(value: string, defaultValue?: any): boolean;
|
|
22
22
|
getString(key: string): string;
|
|
23
23
|
get nodeEnv(): string;
|
|
24
24
|
get fallbackLanguage(): string;
|
|
@@ -65,11 +65,14 @@ let ApiConfigService = ApiConfigService_1 = class ApiConfigService {
|
|
|
65
65
|
const value = this.get(key);
|
|
66
66
|
return ApiConfigService_1.toBoolean(value);
|
|
67
67
|
}
|
|
68
|
-
static toBoolean(value) {
|
|
68
|
+
static toBoolean(value, defaultValue = null) {
|
|
69
69
|
try {
|
|
70
70
|
return Boolean(JSON.parse(value));
|
|
71
71
|
}
|
|
72
72
|
catch (_a) {
|
|
73
|
+
if (!(0, lodash_1.isNil)(defaultValue)) {
|
|
74
|
+
return defaultValue;
|
|
75
|
+
}
|
|
73
76
|
throw new Error(value + ' is not a boolean');
|
|
74
77
|
}
|
|
75
78
|
}
|