@nest-omni/core 1.0.7 → 1.0.9
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 +4 -1
- package/src/boilerplate.polyfill.d.ts +0 -39
- package/src/boilerplate.polyfill.js +0 -78
- package/src/boilerplate.polyfill.ts +0 -202
- package/src/common/abstract-client.service.d.ts +0 -20
- package/src/common/abstract-client.service.js +0 -39
- package/src/common/abstract-client.service.ts +0 -56
- package/src/common/abstract.entity.d.ts +0 -24
- package/src/common/abstract.entity.js +0 -152
- package/src/common/abstract.entity.ts +0 -73
- package/src/common/dto/abstract.dto.d.ts +0 -13
- package/src/common/dto/abstract.dto.js +0 -96
- package/src/common/dto/abstract.dto.ts +0 -64
- package/src/common/dto/bulk-id.dto.d.ts +0 -3
- package/src/common/dto/bulk-id.dto.js +0 -63
- package/src/common/dto/bulk-id.dto.ts +0 -13
- package/src/common/dto/create-translation.dto.d.ts +0 -5
- package/src/common/dto/create-translation.dto.js +0 -63
- package/src/common/dto/create-translation.dto.ts +0 -10
- package/src/common/dto/page-meta.dto.d.ts +0 -15
- package/src/common/dto/page-meta.dto.js +0 -88
- package/src/common/dto/page-meta.dto.ts +0 -37
- package/src/common/dto/page-options.dto.d.ts +0 -8
- package/src/common/dto/page-options.dto.js +0 -87
- package/src/common/dto/page-options.dto.ts +0 -35
- package/src/common/dto/page.dto.d.ts +0 -11
- package/src/common/dto/page.dto.js +0 -94
- package/src/common/dto/page.dto.ts +0 -36
- package/src/common/utils.d.ts +0 -14
- package/src/common/utils.js +0 -39
- package/src/common/utils.ts +0 -45
- package/src/constants/index.d.ts +0 -4
- package/src/constants/index.js +0 -20
- package/src/constants/index.ts +0 -4
- package/src/constants/language-code.d.ts +0 -5
- package/src/constants/language-code.js +0 -10
- package/src/constants/language-code.ts +0 -7
- package/src/constants/order.d.ts +0 -4
- package/src/constants/order.js +0 -8
- package/src/constants/order.ts +0 -4
- package/src/constants/role-type.d.ts +0 -4
- package/src/constants/role-type.js +0 -8
- package/src/constants/role-type.ts +0 -4
- package/src/constants/token-type.d.ts +0 -4
- package/src/constants/token-type.js +0 -8
- package/src/constants/token-type.ts +0 -4
- package/src/decorators/api-page-ok-response.decorator.d.ts +0 -5
- package/src/decorators/api-page-ok-response.decorator.js +0 -25
- package/src/decorators/api-page-ok-response.decorator.ts +0 -31
- package/src/decorators/auth-user.decorator.d.ts +0 -1
- package/src/decorators/auth-user.decorator.js +0 -15
- package/src/decorators/auth-user.decorator.ts +0 -16
- package/src/decorators/controller.decorator.d.ts +0 -1
- package/src/decorators/controller.decorator.js +0 -34
- package/src/decorators/controller.decorator.ts +0 -8
- package/src/decorators/field.decorators.d.ts +0 -71
- package/src/decorators/field.decorators.js +0 -455
- package/src/decorators/field.decorators.ts +0 -773
- package/src/decorators/http.decorators.d.ts +0 -3
- package/src/decorators/http.decorators.js +0 -8
- package/src/decorators/http.decorators.ts +0 -10
- package/src/decorators/index.d.ts +0 -12
- package/src/decorators/index.js +0 -28
- package/src/decorators/index.ts +0 -12
- package/src/decorators/omni-auth.decorator.d.ts +0 -8
- package/src/decorators/omni-auth.decorator.js +0 -60
- package/src/decorators/omni-auth.decorator.ts +0 -46
- package/src/decorators/operation.decorator.d.ts +0 -1
- package/src/decorators/operation.decorator.js +0 -6
- package/src/decorators/operation.decorator.ts +0 -4
- package/src/decorators/property.decorators.d.ts +0 -15
- package/src/decorators/property.decorators.js +0 -36
- package/src/decorators/property.decorators.ts +0 -62
- package/src/decorators/public-route.decorator.d.ts +0 -3
- package/src/decorators/public-route.decorator.js +0 -8
- package/src/decorators/public-route.decorator.ts +0 -8
- package/src/decorators/swagger.schema.d.ts +0 -5
- package/src/decorators/swagger.schema.js +0 -82
- package/src/decorators/swagger.schema.ts +0 -117
- package/src/decorators/timestamp-column.decorator.d.ts +0 -1
- package/src/decorators/timestamp-column.decorator.js +0 -28
- package/src/decorators/timestamp-column.decorator.ts +0 -29
- package/src/decorators/transform.decorators.d.ts +0 -35
- package/src/decorators/transform.decorators.js +0 -122
- package/src/decorators/transform.decorators.ts +0 -147
- package/src/decorators/translate.decorator.d.ts +0 -5
- package/src/decorators/translate.decorator.js +0 -18
- package/src/decorators/translate.decorator.ts +0 -19
- package/src/decorators/use-dto.decorator.d.ts +0 -4
- package/src/decorators/use-dto.decorator.js +0 -9
- package/src/decorators/use-dto.decorator.ts +0 -11
- package/src/decorators/user-check.decorator.d.ts +0 -6
- package/src/decorators/user-check.decorator.js +0 -44
- package/src/decorators/user-check.decorator.ts +0 -30
- package/src/decorators/user.decorator.d.ts +0 -8
- package/src/decorators/user.decorator.js +0 -62
- package/src/decorators/user.decorator.ts +0 -48
- package/src/decorators/user_auth.decorator.d.ts +0 -1
- package/src/decorators/user_auth.decorator.js +0 -16
- package/src/decorators/user_auth.decorator.ts +0 -15
- package/src/decorators/validator.decorators.d.ts +0 -10
- package/src/decorators/validator.decorators.js +0 -59
- package/src/decorators/validator.decorators.ts +0 -78
- package/src/exceptions/file-not-image.exception.d.ts +0 -4
- package/src/exceptions/file-not-image.exception.js +0 -10
- package/src/exceptions/file-not-image.exception.ts +0 -7
- package/src/exceptions/index.d.ts +0 -2
- package/src/exceptions/index.js +0 -18
- package/src/exceptions/index.ts +0 -2
- package/src/exceptions/page-type.exception.d.ts +0 -4
- package/src/exceptions/page-type.exception.js +0 -10
- package/src/exceptions/page-type.exception.ts +0 -7
- package/src/exceptions/user-not-found.exception.d.ts +0 -4
- package/src/exceptions/user-not-found.exception.js +0 -10
- package/src/exceptions/user-not-found.exception.ts +0 -7
- package/src/filters/bad-request.filter.d.ts +0 -5
- package/src/filters/bad-request.filter.js +0 -104
- package/src/filters/bad-request.filter.ts +0 -67
- package/src/filters/constraint-errors.d.ts +0 -1
- package/src/filters/constraint-errors.js +0 -7
- package/src/filters/constraint-errors.ts +0 -5
- package/src/filters/index.d.ts +0 -3
- package/src/filters/index.js +0 -19
- package/src/filters/index.ts +0 -3
- package/src/filters/query-failed.filter.d.ts +0 -10
- package/src/filters/query-failed.filter.js +0 -81
- package/src/filters/query-failed.filter.ts +0 -32
- package/src/health-checker/health-checker.controller.d.ts +0 -15
- package/src/health-checker/health-checker.controller.js +0 -104
- package/src/health-checker/health-checker.controller.ts +0 -51
- package/src/health-checker/health-checker.module.d.ts +0 -2
- package/src/health-checker/health-checker.module.js +0 -69
- package/src/health-checker/health-checker.module.ts +0 -13
- package/src/health-checker/health-indicators/service.indicator.d.ts +0 -8
- package/src/health-checker/health-indicators/service.indicator.js +0 -102
- package/src/health-checker/health-indicators/service.indicator.ts +0 -44
- package/src/helpers/common.helper.d.ts +0 -16
- package/src/helpers/common.helper.js +0 -49
- package/src/helpers/common.helper.ts +0 -49
- package/src/helpers/date.helper.d.ts +0 -10
- package/src/helpers/date.helper.js +0 -81
- package/src/helpers/date.helper.ts +0 -64
- package/src/helpers/excel.helper.d.ts +0 -27
- package/src/helpers/excel.helper.js +0 -338
- package/src/helpers/index.d.ts +0 -3
- package/src/helpers/index.js +0 -19
- package/src/helpers/index.ts +0 -3
- package/src/i18n/en_US/validation.json +0 -38
- package/src/i18n/zh_CN/validation.json +0 -38
- package/src/index.d.ts +0 -11
- package/src/index.js +0 -28
- package/src/index.ts +0 -12
- package/src/interceptors/auth-user.interceptor.d.ts +0 -4
- package/src/interceptors/auth-user.interceptor.js +0 -68
- package/src/interceptors/auth-user.interceptor.ts +0 -20
- package/src/interceptors/index.d.ts +0 -2
- package/src/interceptors/index.js +0 -18
- package/src/interceptors/index.ts +0 -2
- package/src/interceptors/language-interceptor.service.d.ts +0 -6
- package/src/interceptors/language-interceptor.service.js +0 -74
- package/src/interceptors/language-interceptor.service.ts +0 -31
- package/src/interceptors/translation-interceptor.service.d.ts +0 -5
- package/src/interceptors/translation-interceptor.service.js +0 -83
- package/src/interceptors/translation-interceptor.service.ts +0 -43
- package/src/interfaces/IApiFile.d.ts +0 -4
- package/src/interfaces/IApiFile.js +0 -2
- package/src/interfaces/IApiFile.ts +0 -4
- package/src/interfaces/IFile.d.ts +0 -9
- package/src/interfaces/IFile.js +0 -2
- package/src/interfaces/IFile.ts +0 -8
- package/src/interfaces/ITranslationDecoratorInterface.d.ts +0 -3
- package/src/interfaces/ITranslationDecoratorInterface.js +0 -2
- package/src/interfaces/ITranslationDecoratorInterface.ts +0 -3
- package/src/interfaces/index.d.ts +0 -3
- package/src/interfaces/index.js +0 -19
- package/src/interfaces/index.ts +0 -3
- package/src/interfaces/response.d.ts +0 -25
- package/src/interfaces/response.js +0 -2
- package/src/interfaces/response.ts +0 -37
- package/src/middlewares/index.d.ts +0 -3
- package/src/middlewares/index.js +0 -19
- package/src/middlewares/index.ts +0 -3
- package/src/middlewares/omni-auth.middleware.d.ts +0 -1
- package/src/middlewares/omni-auth.middleware.js +0 -13
- package/src/middlewares/omni-auth.middleware.ts +0 -10
- package/src/middlewares/powerby.middleware.d.ts +0 -1
- package/src/middlewares/powerby.middleware.js +0 -10
- package/src/middlewares/powerby.middleware.ts +0 -6
- package/src/middlewares/request-id.middleware.d.ts +0 -7
- package/src/middlewares/request-id.middleware.js +0 -22
- package/src/middlewares/request-id.middleware.ts +0 -28
- package/src/providers/context.provider.d.ts +0 -32
- package/src/providers/context.provider.js +0 -73
- package/src/providers/context.provider.ts +0 -98
- package/src/providers/generator.provider.d.ts +0 -13
- package/src/providers/generator.provider.js +0 -54
- package/src/providers/generator.provider.ts +0 -66
- package/src/providers/index.d.ts +0 -2
- package/src/providers/index.js +0 -18
- package/src/providers/index.ts +0 -2
- package/src/setup/bootstrap.setup.d.ts +0 -5
- package/src/setup/bootstrap.setup.js +0 -138
- package/src/setup/bootstrap.setup.ts +0 -139
- package/src/setup/index.d.ts +0 -1
- package/src/setup/index.js +0 -17
- package/src/setup/index.ts +0 -1
- package/src/setup/microservices.setup.js +0 -55
- package/src/setup-swagger.d.ts +0 -2
- package/src/setup-swagger.js +0 -62
- package/src/setup-swagger.ts +0 -67
- package/src/shared/index.d.ts +0 -2
- package/src/shared/index.js +0 -18
- package/src/shared/index.ts +0 -2
- package/src/shared/serviceRegistryModule.d.ts +0 -2
- package/src/shared/serviceRegistryModule.js +0 -176
- package/src/shared/serviceRegistryModule.ts +0 -110
- package/src/shared/services/api-config.service.d.ts +0 -73
- package/src/shared/services/api-config.service.js +0 -335
- package/src/shared/services/api-config.service.ts +0 -319
- package/src/shared/services/aws-s3.service.d.ts +0 -10
- package/src/shared/services/aws-s3.service.js +0 -96
- package/src/shared/services/aws-s3.service.ts +0 -39
- package/src/shared/services/generator.service.d.ts +0 -4
- package/src/shared/services/generator.service.js +0 -67
- package/src/shared/services/generator.service.ts +0 -13
- package/src/shared/services/index.d.ts +0 -5
- package/src/shared/services/index.js +0 -21
- package/src/shared/services/index.ts +0 -5
- package/src/shared/services/translation.service.d.ts +0 -9
- package/src/shared/services/translation.service.js +0 -109
- package/src/shared/services/translation.service.ts +0 -59
- package/src/shared/services/validator.service.d.ts +0 -3
- package/src/shared/services/validator.service.js +0 -64
- package/src/shared/services/validator.service.ts +0 -10
- package/src/snake-naming.strategy.d.ts +0 -11
- package/src/snake-naming.strategy.js +0 -37
- package/src/snake-naming.strategy.ts +0 -64
- package/src/types.d.ts +0 -9
- package/src/types.js +0 -2
- package/src/types.ts +0 -44
- package/src/validators/file-mimetype.validator.d.ts +0 -13
- package/src/validators/file-mimetype.validator.js +0 -21
- package/src/validators/file-mimetype.validator.ts +0 -34
- package/src/validators/index.d.ts +0 -3
- package/src/validators/index.js +0 -19
- package/src/validators/index.ts +0 -3
- package/src/validators/is-exists.validator.d.ts +0 -18
- package/src/validators/is-exists.validator.js +0 -99
- package/src/validators/is-exists.validator.ts +0 -60
- package/src/validators/is-unique.validator.d.ts +0 -17
- package/src/validators/is-unique.validator.js +0 -131
- package/src/validators/is-unique.validator.ts +0 -93
- package/src/validators/phone-country-code.validator.d.ts +0 -2
- package/src/validators/phone-country-code.validator.js +0 -30
- package/src/validators/phone-country-code.validator.ts +0 -36
- package/src/validators/same-as.validator.d.ts +0 -2
- package/src/validators/same-as.validator.js +0 -25
- package/src/validators/same-as.validator.ts +0 -27
- package/src/validators/skip-empty.validator.d.ts +0 -6
- package/src/validators/skip-empty.validator.js +0 -23
- package/src/validators/skip-empty.validator.ts +0 -25
- package/tsconfig.json +0 -30
- package/tsconfig.lib.json +0 -16
- package/tsconfig.tsbuildinfo +0 -1
|
@@ -1,335 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __esDecorate = (this && this.__esDecorate) || function (ctor, descriptorIn, decorators, contextIn, initializers, extraInitializers) {
|
|
3
|
-
function accept(f) { if (f !== void 0 && typeof f !== "function") throw new TypeError("Function expected"); return f; }
|
|
4
|
-
var kind = contextIn.kind, key = kind === "getter" ? "get" : kind === "setter" ? "set" : "value";
|
|
5
|
-
var target = !descriptorIn && ctor ? contextIn["static"] ? ctor : ctor.prototype : null;
|
|
6
|
-
var descriptor = descriptorIn || (target ? Object.getOwnPropertyDescriptor(target, contextIn.name) : {});
|
|
7
|
-
var _, done = false;
|
|
8
|
-
for (var i = decorators.length - 1; i >= 0; i--) {
|
|
9
|
-
var context = {};
|
|
10
|
-
for (var p in contextIn) context[p] = p === "access" ? {} : contextIn[p];
|
|
11
|
-
for (var p in contextIn.access) context.access[p] = contextIn.access[p];
|
|
12
|
-
context.addInitializer = function (f) { if (done) throw new TypeError("Cannot add initializers after decoration has completed"); extraInitializers.push(accept(f || null)); };
|
|
13
|
-
var result = (0, decorators[i])(kind === "accessor" ? { get: descriptor.get, set: descriptor.set } : descriptor[key], context);
|
|
14
|
-
if (kind === "accessor") {
|
|
15
|
-
if (result === void 0) continue;
|
|
16
|
-
if (result === null || typeof result !== "object") throw new TypeError("Object expected");
|
|
17
|
-
if (_ = accept(result.get)) descriptor.get = _;
|
|
18
|
-
if (_ = accept(result.set)) descriptor.set = _;
|
|
19
|
-
if (_ = accept(result.init)) initializers.unshift(_);
|
|
20
|
-
}
|
|
21
|
-
else if (_ = accept(result)) {
|
|
22
|
-
if (kind === "field") initializers.unshift(_);
|
|
23
|
-
else descriptor[key] = _;
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
if (target) Object.defineProperty(target, contextIn.name, descriptor);
|
|
27
|
-
done = true;
|
|
28
|
-
};
|
|
29
|
-
var __runInitializers = (this && this.__runInitializers) || function (thisArg, initializers, value) {
|
|
30
|
-
var useValue = arguments.length > 2;
|
|
31
|
-
for (var i = 0; i < initializers.length; i++) {
|
|
32
|
-
value = useValue ? initializers[i].call(thisArg, value) : initializers[i].call(thisArg);
|
|
33
|
-
}
|
|
34
|
-
return useValue ? value : void 0;
|
|
35
|
-
};
|
|
36
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
37
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
38
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
39
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
40
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
41
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
42
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
43
|
-
});
|
|
44
|
-
};
|
|
45
|
-
var __setFunctionName = (this && this.__setFunctionName) || function (f, name, prefix) {
|
|
46
|
-
if (typeof name === "symbol") name = name.description ? "[".concat(name.description, "]") : "";
|
|
47
|
-
return Object.defineProperty(f, "name", { configurable: true, value: prefix ? "".concat(prefix, " ", name) : name });
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
exports.ApiConfigService = void 0;
|
|
54
|
-
const common_1 = require("@nestjs/common");
|
|
55
|
-
const lodash_1 = require("lodash");
|
|
56
|
-
const snake_naming_strategy_1 = require("../../snake-naming.strategy");
|
|
57
|
-
const cache_manager_ioredis_yet_1 = require("cache-manager-ioredis-yet");
|
|
58
|
-
const connect_redis_1 = __importDefault(require("connect-redis"));
|
|
59
|
-
const ioredis_1 = __importDefault(require("ioredis"));
|
|
60
|
-
let ApiConfigService = (() => {
|
|
61
|
-
let _classDecorators = [(0, common_1.Injectable)()];
|
|
62
|
-
let _classDescriptor;
|
|
63
|
-
let _classExtraInitializers = [];
|
|
64
|
-
let _classThis;
|
|
65
|
-
var ApiConfigService = _classThis = class {
|
|
66
|
-
constructor(configService) {
|
|
67
|
-
this.configService = configService;
|
|
68
|
-
}
|
|
69
|
-
static getRootPath() {
|
|
70
|
-
if (!ApiConfigService.rootPath) {
|
|
71
|
-
throw new Error(`rootPath is not set`);
|
|
72
|
-
}
|
|
73
|
-
return ApiConfigService.rootPath;
|
|
74
|
-
}
|
|
75
|
-
get isDev() {
|
|
76
|
-
return this.nodeEnv === 'dev';
|
|
77
|
-
}
|
|
78
|
-
get isProd() {
|
|
79
|
-
return this.nodeEnv === 'prod';
|
|
80
|
-
}
|
|
81
|
-
get isSit() {
|
|
82
|
-
return this.nodeEnv === 'sit';
|
|
83
|
-
}
|
|
84
|
-
get isUat() {
|
|
85
|
-
return this.nodeEnv === 'uat';
|
|
86
|
-
}
|
|
87
|
-
get isTest() {
|
|
88
|
-
return this.nodeEnv === 'test';
|
|
89
|
-
}
|
|
90
|
-
getNumber(key) {
|
|
91
|
-
const value = this.get(key);
|
|
92
|
-
try {
|
|
93
|
-
return Number(value);
|
|
94
|
-
}
|
|
95
|
-
catch (_a) {
|
|
96
|
-
throw new Error(key + ' environment variable is not a number');
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
getBoolean(key) {
|
|
100
|
-
const value = this.get(key);
|
|
101
|
-
return ApiConfigService.toBoolean(value);
|
|
102
|
-
}
|
|
103
|
-
static toBoolean(value) {
|
|
104
|
-
try {
|
|
105
|
-
return Boolean(JSON.parse(value));
|
|
106
|
-
}
|
|
107
|
-
catch (_a) {
|
|
108
|
-
throw new Error(value + ' is not a boolean');
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
getString(key) {
|
|
112
|
-
const value = this.get(key);
|
|
113
|
-
return value.replace(/\\n/g, '\n');
|
|
114
|
-
}
|
|
115
|
-
get nodeEnv() {
|
|
116
|
-
return this.getString('NODE_ENV');
|
|
117
|
-
}
|
|
118
|
-
get fallbackLanguage() {
|
|
119
|
-
return this.getString('FALLBACK_LANGUAGE');
|
|
120
|
-
}
|
|
121
|
-
get sentryConfig() {
|
|
122
|
-
return {
|
|
123
|
-
dsn: this.getString('SENTRY_DSN'),
|
|
124
|
-
debug: this.isDev,
|
|
125
|
-
environment: this.nodeEnv,
|
|
126
|
-
tracesSampleRate: 1.0,
|
|
127
|
-
release: '0.0.1',
|
|
128
|
-
logLevels: ['warn', 'error'],
|
|
129
|
-
close: {
|
|
130
|
-
enabled: true,
|
|
131
|
-
// Time in milliseconds to forcefully quit the application
|
|
132
|
-
timeout: 10 * 1000,
|
|
133
|
-
},
|
|
134
|
-
};
|
|
135
|
-
}
|
|
136
|
-
get typeormConfig() {
|
|
137
|
-
return {
|
|
138
|
-
autoLoadEntities: true,
|
|
139
|
-
keepConnectionAlive: !this.isDev,
|
|
140
|
-
dropSchema: this.isTest,
|
|
141
|
-
type: 'mysql',
|
|
142
|
-
host: this.getString('DB_HOST'),
|
|
143
|
-
port: this.getNumber('DB_PORT'),
|
|
144
|
-
username: this.getString('DB_USERNAME'),
|
|
145
|
-
password: this.getString('DB_PASSWORD'),
|
|
146
|
-
database: this.getString('DB_DATABASE'),
|
|
147
|
-
subscribers: [],
|
|
148
|
-
synchronize: this.isDev,
|
|
149
|
-
migrationsRun: true,
|
|
150
|
-
logging: this.getBoolean('DB_LOG_ENABLED'),
|
|
151
|
-
maxQueryExecutionTime: 3000,
|
|
152
|
-
namingStrategy: new snake_naming_strategy_1.SnakeNamingStrategy(),
|
|
153
|
-
};
|
|
154
|
-
}
|
|
155
|
-
get awsS3Config() {
|
|
156
|
-
return {
|
|
157
|
-
bucketRegion: this.getString('AWS_S3_BUCKET_REGION'),
|
|
158
|
-
bucketApiVersion: this.getString('AWS_S3_API_VERSION'),
|
|
159
|
-
bucketName: this.getString('AWS_S3_BUCKET_NAME'),
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
get documentationEnabled() {
|
|
163
|
-
return this.getBoolean('SWAGGER_ENABLED');
|
|
164
|
-
}
|
|
165
|
-
get documentationPath() {
|
|
166
|
-
return this.getString('SWAGGER_PATH');
|
|
167
|
-
}
|
|
168
|
-
get skywalkingEnabled() {
|
|
169
|
-
return this.getBoolean('SW_ENABLED');
|
|
170
|
-
}
|
|
171
|
-
get viewsEnabled() {
|
|
172
|
-
return this.getBoolean('VIEWS_ENABLED');
|
|
173
|
-
}
|
|
174
|
-
get sessionEnabled() {
|
|
175
|
-
return this.getBoolean('SESSION_ENABLED');
|
|
176
|
-
}
|
|
177
|
-
get corsEnabled() {
|
|
178
|
-
try {
|
|
179
|
-
return this.getBoolean('CORS_ENABLED');
|
|
180
|
-
}
|
|
181
|
-
catch (error) {
|
|
182
|
-
return false;
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
get corsConfig() {
|
|
186
|
-
const allowedDomains = this.getString('CORS_ORIGIN').split(',');
|
|
187
|
-
return {
|
|
188
|
-
origin: (origin, callback) => {
|
|
189
|
-
if (!origin ||
|
|
190
|
-
allowedDomains.some((domain) => origin.endsWith(domain))) {
|
|
191
|
-
callback(null, origin);
|
|
192
|
-
}
|
|
193
|
-
else {
|
|
194
|
-
callback(new common_1.BadRequestException('Not allowed by CORS'));
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
methods: this.getString('CORS_METHODS'),
|
|
198
|
-
allowedHeaders: this.getString('CORS_ALLOWED_HEADERS'),
|
|
199
|
-
exposedHeaders: this.getString('CORS_EXPOSED_HEADERS'),
|
|
200
|
-
credentials: this.getBoolean('CORS_CREDENTIALS'),
|
|
201
|
-
optionsSuccessStatus: 200,
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
get sessionConfig() {
|
|
205
|
-
const config = {
|
|
206
|
-
secret: this.getString('SESSION_KEY'),
|
|
207
|
-
resave: false,
|
|
208
|
-
saveUninitialized: false,
|
|
209
|
-
};
|
|
210
|
-
if (this.getBoolean('SESSION_REDIS_ENABLED')) {
|
|
211
|
-
config.store = new connect_redis_1.default({
|
|
212
|
-
client: new ioredis_1.default(this.ioRedisConfig),
|
|
213
|
-
prefix: this.getString('SESSION_REDIS_PREFIX'),
|
|
214
|
-
});
|
|
215
|
-
}
|
|
216
|
-
return config;
|
|
217
|
-
}
|
|
218
|
-
get natsEnabled() {
|
|
219
|
-
return this.getBoolean('NATS_ENABLED');
|
|
220
|
-
}
|
|
221
|
-
get natsConfig() {
|
|
222
|
-
return {
|
|
223
|
-
host: this.getString('NATS_HOST'),
|
|
224
|
-
port: this.getNumber('NATS_PORT'),
|
|
225
|
-
};
|
|
226
|
-
}
|
|
227
|
-
get authConfig() {
|
|
228
|
-
return {
|
|
229
|
-
privateKey: this.getString('JWT_PRIVATE_KEY'),
|
|
230
|
-
publicKey: this.getString('JWT_PUBLIC_KEY'),
|
|
231
|
-
jwtExpirationTime: this.getNumber('JWT_EXPIRATION_TIME'),
|
|
232
|
-
};
|
|
233
|
-
}
|
|
234
|
-
get appConfig() {
|
|
235
|
-
return {
|
|
236
|
-
port: this.getString('PORT'),
|
|
237
|
-
};
|
|
238
|
-
}
|
|
239
|
-
get apiKey() {
|
|
240
|
-
return this.getString('API_KEY');
|
|
241
|
-
}
|
|
242
|
-
get ioRedisConfig() {
|
|
243
|
-
return {
|
|
244
|
-
host: this.getString('REDIS_HOST'),
|
|
245
|
-
port: this.getNumber('REDIS_PORT'),
|
|
246
|
-
username: this.getString('REDIS_USERNAME'),
|
|
247
|
-
password: this.getString('REDIS_PASSWORD'),
|
|
248
|
-
db: this.getNumber('REDIS_DB'),
|
|
249
|
-
};
|
|
250
|
-
}
|
|
251
|
-
/**
|
|
252
|
-
* 是否使用Redis,用于health check
|
|
253
|
-
*/
|
|
254
|
-
get isRedisEnabled() {
|
|
255
|
-
return (this.getBoolean('BULL_ENABLED') ||
|
|
256
|
-
this.getBoolean('CACHE_ENABLED') ||
|
|
257
|
-
(this.sessionEnabled && this.getBoolean('SESSION_REDIS_ENABLED')));
|
|
258
|
-
}
|
|
259
|
-
get bullConfig() {
|
|
260
|
-
return {
|
|
261
|
-
redis: this.ioRedisConfig,
|
|
262
|
-
prefix: this.getString('BULL_PREFIX'),
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
cacheConfig() {
|
|
266
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
267
|
-
return {
|
|
268
|
-
isGlobal: true,
|
|
269
|
-
store: yield (0, cache_manager_ioredis_yet_1.redisStore)(Object.assign(Object.assign({}, this.ioRedisConfig), { ttl: this.getNumber('CACHE_TTL') })),
|
|
270
|
-
};
|
|
271
|
-
});
|
|
272
|
-
}
|
|
273
|
-
get pinoConfig() {
|
|
274
|
-
const transport = this.isDev
|
|
275
|
-
? {
|
|
276
|
-
target: 'pino-pretty',
|
|
277
|
-
}
|
|
278
|
-
: null;
|
|
279
|
-
return {
|
|
280
|
-
pinoHttp: {
|
|
281
|
-
genReqId: (req) => req.id,
|
|
282
|
-
transport,
|
|
283
|
-
level: this.isDev ? 'debug' : 'info',
|
|
284
|
-
customLogLevel: function (res) {
|
|
285
|
-
if (res.statusCode < 300) {
|
|
286
|
-
return 'info';
|
|
287
|
-
}
|
|
288
|
-
else if (res.statusCode >= 300 && res.statusCode < 500) {
|
|
289
|
-
return 'warn';
|
|
290
|
-
}
|
|
291
|
-
return 'error';
|
|
292
|
-
},
|
|
293
|
-
customProps: (req) => {
|
|
294
|
-
return {
|
|
295
|
-
env: this.nodeEnv,
|
|
296
|
-
appName: this.getString('NAME'),
|
|
297
|
-
user: req === null || req === void 0 ? void 0 : req.user,
|
|
298
|
-
body: req === null || req === void 0 ? void 0 : req.body,
|
|
299
|
-
};
|
|
300
|
-
},
|
|
301
|
-
redact: {
|
|
302
|
-
paths: ['req.headers.authorization', 'req.headers.apikey'],
|
|
303
|
-
remove: true,
|
|
304
|
-
},
|
|
305
|
-
},
|
|
306
|
-
};
|
|
307
|
-
}
|
|
308
|
-
get axiosProxyConfig() {
|
|
309
|
-
if (!this.getBoolean('DIRECT_PROXY_ENABLED')) {
|
|
310
|
-
return false;
|
|
311
|
-
}
|
|
312
|
-
return {
|
|
313
|
-
host: this.getString('DIRECT_PROXY_HOST'),
|
|
314
|
-
port: this.getNumber('DIRECT_PROXY_PORT'),
|
|
315
|
-
};
|
|
316
|
-
}
|
|
317
|
-
get(key) {
|
|
318
|
-
const value = this.configService.get(key);
|
|
319
|
-
if ((0, lodash_1.isNil)(value)) {
|
|
320
|
-
throw new Error(key + ' environment variable does not set'); // probably we should call process.exit() too to avoid locking the service
|
|
321
|
-
}
|
|
322
|
-
return value;
|
|
323
|
-
}
|
|
324
|
-
};
|
|
325
|
-
__setFunctionName(_classThis, "ApiConfigService");
|
|
326
|
-
(() => {
|
|
327
|
-
const _metadata = typeof Symbol === "function" && Symbol.metadata ? Object.create(null) : void 0;
|
|
328
|
-
__esDecorate(null, _classDescriptor = { value: _classThis }, _classDecorators, { kind: "class", name: _classThis.name, metadata: _metadata }, null, _classExtraInitializers);
|
|
329
|
-
ApiConfigService = _classThis = _classDescriptor.value;
|
|
330
|
-
if (_metadata) Object.defineProperty(_classThis, Symbol.metadata, { enumerable: true, configurable: true, writable: true, value: _metadata });
|
|
331
|
-
__runInitializers(_classThis, _classExtraInitializers);
|
|
332
|
-
})();
|
|
333
|
-
return ApiConfigService = _classThis;
|
|
334
|
-
})();
|
|
335
|
-
exports.ApiConfigService = ApiConfigService;
|
|
@@ -1,319 +0,0 @@
|
|
|
1
|
-
import { BadRequestException, Injectable } from '@nestjs/common';
|
|
2
|
-
import { ConfigService } from '@nestjs/config';
|
|
3
|
-
import type { TypeOrmModuleOptions } from '@nestjs/typeorm';
|
|
4
|
-
import { isNil } from 'lodash';
|
|
5
|
-
import { SnakeNamingStrategy } from '../../snake-naming.strategy';
|
|
6
|
-
import { SentryModuleOptions } from '@ntegral/nestjs-sentry/lib/sentry.interfaces';
|
|
7
|
-
import session from 'express-session';
|
|
8
|
-
import { Params } from 'nestjs-pino';
|
|
9
|
-
import { redisStore } from 'cache-manager-ioredis-yet';
|
|
10
|
-
import { BullRootModuleOptions } from '@nestjs/bull/dist/interfaces/bull-module-options.interface';
|
|
11
|
-
import RedisStore from 'connect-redis';
|
|
12
|
-
import Redis from 'ioredis';
|
|
13
|
-
import { AxiosProxyConfig } from 'axios';
|
|
14
|
-
import { CorsOptions } from '@nestjs/common/interfaces/external/cors-options.interface';
|
|
15
|
-
|
|
16
|
-
@Injectable()
|
|
17
|
-
export class ApiConfigService {
|
|
18
|
-
static rootPath: string;
|
|
19
|
-
|
|
20
|
-
constructor(private configService: ConfigService) {}
|
|
21
|
-
|
|
22
|
-
static getRootPath(): string {
|
|
23
|
-
if (!ApiConfigService.rootPath) {
|
|
24
|
-
throw new Error(`rootPath is not set`);
|
|
25
|
-
}
|
|
26
|
-
return ApiConfigService.rootPath;
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
get isDev(): boolean {
|
|
30
|
-
return this.nodeEnv === 'dev';
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
get isProd(): boolean {
|
|
34
|
-
return this.nodeEnv === 'prod';
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
get isSit(): boolean {
|
|
38
|
-
return this.nodeEnv === 'sit';
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
get isUat(): boolean {
|
|
42
|
-
return this.nodeEnv === 'uat';
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
get isTest(): boolean {
|
|
46
|
-
return this.nodeEnv === 'test';
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
getNumber(key: string): number {
|
|
50
|
-
const value = this.get(key);
|
|
51
|
-
|
|
52
|
-
try {
|
|
53
|
-
return Number(value);
|
|
54
|
-
} catch {
|
|
55
|
-
throw new Error(key + ' environment variable is not a number');
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
getBoolean(key: string): boolean {
|
|
60
|
-
const value = this.get(key);
|
|
61
|
-
|
|
62
|
-
return ApiConfigService.toBoolean(value);
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
static toBoolean(value: string): boolean {
|
|
66
|
-
try {
|
|
67
|
-
return Boolean(JSON.parse(value));
|
|
68
|
-
} catch {
|
|
69
|
-
throw new Error(value + ' is not a boolean');
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
getString(key: string): string {
|
|
74
|
-
const value = this.get(key);
|
|
75
|
-
|
|
76
|
-
return value.replace(/\\n/g, '\n');
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
get nodeEnv(): string {
|
|
80
|
-
return this.getString('NODE_ENV');
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
get fallbackLanguage(): string {
|
|
84
|
-
return this.getString('FALLBACK_LANGUAGE');
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
get sentryConfig(): SentryModuleOptions {
|
|
88
|
-
return {
|
|
89
|
-
dsn: this.getString('SENTRY_DSN'),
|
|
90
|
-
debug: this.isDev,
|
|
91
|
-
environment: this.nodeEnv,
|
|
92
|
-
tracesSampleRate: 1.0,
|
|
93
|
-
release: '0.0.1', // must create a release in sentry.io dashboard
|
|
94
|
-
logLevels: ['warn', 'error'],
|
|
95
|
-
close: {
|
|
96
|
-
enabled: true,
|
|
97
|
-
// Time in milliseconds to forcefully quit the application
|
|
98
|
-
timeout: 10 * 1000,
|
|
99
|
-
},
|
|
100
|
-
};
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
get typeormConfig(): TypeOrmModuleOptions {
|
|
104
|
-
return {
|
|
105
|
-
autoLoadEntities: true,
|
|
106
|
-
keepConnectionAlive: !this.isDev,
|
|
107
|
-
dropSchema: this.isTest,
|
|
108
|
-
type: 'mysql',
|
|
109
|
-
host: this.getString('DB_HOST'),
|
|
110
|
-
port: this.getNumber('DB_PORT'),
|
|
111
|
-
username: this.getString('DB_USERNAME'),
|
|
112
|
-
password: this.getString('DB_PASSWORD'),
|
|
113
|
-
database: this.getString('DB_DATABASE'),
|
|
114
|
-
subscribers: [],
|
|
115
|
-
synchronize: this.isDev,
|
|
116
|
-
migrationsRun: true,
|
|
117
|
-
logging: this.getBoolean('DB_LOG_ENABLED'),
|
|
118
|
-
maxQueryExecutionTime: 3000,
|
|
119
|
-
namingStrategy: new SnakeNamingStrategy(),
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
get awsS3Config() {
|
|
124
|
-
return {
|
|
125
|
-
bucketRegion: this.getString('AWS_S3_BUCKET_REGION'),
|
|
126
|
-
bucketApiVersion: this.getString('AWS_S3_API_VERSION'),
|
|
127
|
-
bucketName: this.getString('AWS_S3_BUCKET_NAME'),
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
get documentationEnabled(): boolean {
|
|
132
|
-
return this.getBoolean('SWAGGER_ENABLED');
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
get documentationPath(): string {
|
|
136
|
-
return this.getString('SWAGGER_PATH');
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
get skywalkingEnabled(): boolean {
|
|
140
|
-
return this.getBoolean('SW_ENABLED');
|
|
141
|
-
}
|
|
142
|
-
|
|
143
|
-
get viewsEnabled(): boolean {
|
|
144
|
-
return this.getBoolean('VIEWS_ENABLED');
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
get sessionEnabled(): boolean {
|
|
148
|
-
return this.getBoolean('SESSION_ENABLED');
|
|
149
|
-
}
|
|
150
|
-
|
|
151
|
-
get corsEnabled(): boolean {
|
|
152
|
-
try {
|
|
153
|
-
return this.getBoolean('CORS_ENABLED');
|
|
154
|
-
} catch (error) {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
|
|
159
|
-
get corsConfig(): CorsOptions {
|
|
160
|
-
const allowedDomains = this.getString('CORS_ORIGIN').split(',');
|
|
161
|
-
return {
|
|
162
|
-
origin: (origin, callback) => {
|
|
163
|
-
if (
|
|
164
|
-
!origin ||
|
|
165
|
-
allowedDomains.some((domain) => origin.endsWith(domain))
|
|
166
|
-
) {
|
|
167
|
-
callback(null, origin);
|
|
168
|
-
} else {
|
|
169
|
-
callback(new BadRequestException('Not allowed by CORS'));
|
|
170
|
-
}
|
|
171
|
-
},
|
|
172
|
-
methods: this.getString('CORS_METHODS'),
|
|
173
|
-
allowedHeaders: this.getString('CORS_ALLOWED_HEADERS'),
|
|
174
|
-
exposedHeaders: this.getString('CORS_EXPOSED_HEADERS'),
|
|
175
|
-
credentials: this.getBoolean('CORS_CREDENTIALS'),
|
|
176
|
-
optionsSuccessStatus: 200,
|
|
177
|
-
};
|
|
178
|
-
}
|
|
179
|
-
|
|
180
|
-
get sessionConfig(): session.SessionOptions {
|
|
181
|
-
const config: session.SessionOptions = {
|
|
182
|
-
secret: this.getString('SESSION_KEY'),
|
|
183
|
-
resave: false,
|
|
184
|
-
saveUninitialized: false,
|
|
185
|
-
};
|
|
186
|
-
|
|
187
|
-
if (this.getBoolean('SESSION_REDIS_ENABLED')) {
|
|
188
|
-
config.store = new RedisStore({
|
|
189
|
-
client: new Redis(this.ioRedisConfig),
|
|
190
|
-
prefix: this.getString('SESSION_REDIS_PREFIX'),
|
|
191
|
-
});
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return config;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
get natsEnabled(): boolean {
|
|
198
|
-
return this.getBoolean('NATS_ENABLED');
|
|
199
|
-
}
|
|
200
|
-
|
|
201
|
-
get natsConfig() {
|
|
202
|
-
return {
|
|
203
|
-
host: this.getString('NATS_HOST'),
|
|
204
|
-
port: this.getNumber('NATS_PORT'),
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
|
|
208
|
-
get authConfig() {
|
|
209
|
-
return {
|
|
210
|
-
privateKey: this.getString('JWT_PRIVATE_KEY'),
|
|
211
|
-
publicKey: this.getString('JWT_PUBLIC_KEY'),
|
|
212
|
-
jwtExpirationTime: this.getNumber('JWT_EXPIRATION_TIME'),
|
|
213
|
-
};
|
|
214
|
-
}
|
|
215
|
-
|
|
216
|
-
get appConfig() {
|
|
217
|
-
return {
|
|
218
|
-
port: this.getString('PORT'),
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
get apiKey(): string {
|
|
223
|
-
return this.getString('API_KEY');
|
|
224
|
-
}
|
|
225
|
-
|
|
226
|
-
get ioRedisConfig() {
|
|
227
|
-
return {
|
|
228
|
-
host: this.getString('REDIS_HOST'),
|
|
229
|
-
port: this.getNumber('REDIS_PORT'),
|
|
230
|
-
username: this.getString('REDIS_USERNAME'),
|
|
231
|
-
password: this.getString('REDIS_PASSWORD'),
|
|
232
|
-
db: this.getNumber('REDIS_DB'),
|
|
233
|
-
};
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* 是否使用Redis,用于health check
|
|
238
|
-
*/
|
|
239
|
-
get isRedisEnabled(): boolean {
|
|
240
|
-
return (
|
|
241
|
-
this.getBoolean('BULL_ENABLED') ||
|
|
242
|
-
this.getBoolean('CACHE_ENABLED') ||
|
|
243
|
-
(this.sessionEnabled && this.getBoolean('SESSION_REDIS_ENABLED'))
|
|
244
|
-
);
|
|
245
|
-
}
|
|
246
|
-
|
|
247
|
-
get bullConfig(): BullRootModuleOptions {
|
|
248
|
-
return {
|
|
249
|
-
redis: this.ioRedisConfig,
|
|
250
|
-
prefix: this.getString('BULL_PREFIX'),
|
|
251
|
-
};
|
|
252
|
-
}
|
|
253
|
-
|
|
254
|
-
async cacheConfig() {
|
|
255
|
-
return {
|
|
256
|
-
isGlobal: true,
|
|
257
|
-
store: await redisStore({
|
|
258
|
-
...this.ioRedisConfig,
|
|
259
|
-
ttl: this.getNumber('CACHE_TTL'),
|
|
260
|
-
}),
|
|
261
|
-
};
|
|
262
|
-
}
|
|
263
|
-
|
|
264
|
-
get pinoConfig(): Params {
|
|
265
|
-
const transport = this.isDev
|
|
266
|
-
? {
|
|
267
|
-
target: 'pino-pretty',
|
|
268
|
-
}
|
|
269
|
-
: null;
|
|
270
|
-
|
|
271
|
-
return {
|
|
272
|
-
pinoHttp: {
|
|
273
|
-
genReqId: (req: any) => req.id,
|
|
274
|
-
transport,
|
|
275
|
-
level: this.isDev ? 'debug' : 'info',
|
|
276
|
-
customLogLevel: function (res: any) {
|
|
277
|
-
if (res.statusCode < 300) {
|
|
278
|
-
return 'info';
|
|
279
|
-
} else if (res.statusCode >= 300 && res.statusCode < 500) {
|
|
280
|
-
return 'warn';
|
|
281
|
-
}
|
|
282
|
-
return 'error';
|
|
283
|
-
},
|
|
284
|
-
customProps: (req: any) => {
|
|
285
|
-
return {
|
|
286
|
-
env: this.nodeEnv,
|
|
287
|
-
appName: this.getString('NAME'),
|
|
288
|
-
user: req?.user,
|
|
289
|
-
body: req?.body,
|
|
290
|
-
};
|
|
291
|
-
},
|
|
292
|
-
redact: {
|
|
293
|
-
paths: ['req.headers.authorization', 'req.headers.apikey'],
|
|
294
|
-
remove: true,
|
|
295
|
-
},
|
|
296
|
-
},
|
|
297
|
-
};
|
|
298
|
-
}
|
|
299
|
-
|
|
300
|
-
get axiosProxyConfig(): AxiosProxyConfig | false {
|
|
301
|
-
if (!this.getBoolean('DIRECT_PROXY_ENABLED')) {
|
|
302
|
-
return false;
|
|
303
|
-
}
|
|
304
|
-
return {
|
|
305
|
-
host: this.getString('DIRECT_PROXY_HOST'),
|
|
306
|
-
port: this.getNumber('DIRECT_PROXY_PORT'),
|
|
307
|
-
};
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
private get(key: string): string {
|
|
311
|
-
const value = this.configService.get<string>(key);
|
|
312
|
-
|
|
313
|
-
if (isNil(value)) {
|
|
314
|
-
throw new Error(key + ' environment variable does not set'); // probably we should call process.exit() too to avoid locking the service
|
|
315
|
-
}
|
|
316
|
-
|
|
317
|
-
return value;
|
|
318
|
-
}
|
|
319
|
-
}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { IFile } from '../../interfaces';
|
|
2
|
-
import { ApiConfigService } from './api-config.service';
|
|
3
|
-
import { GeneratorService } from './generator.service';
|
|
4
|
-
export declare class AwsS3Service {
|
|
5
|
-
configService: ApiConfigService;
|
|
6
|
-
generatorService: GeneratorService;
|
|
7
|
-
private readonly s3;
|
|
8
|
-
constructor(configService: ApiConfigService, generatorService: GeneratorService);
|
|
9
|
-
uploadImage(file: IFile): Promise<string>;
|
|
10
|
-
}
|