167 lines
6.1 KiB
JavaScript
167 lines
6.1 KiB
JavaScript
"use strict";
|
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
};
|
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
};
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
exports.validateEnv = validateEnv;
|
|
const class_transformer_1 = require("class-transformer");
|
|
const class_validator_1 = require("class-validator");
|
|
class EnvironmentVariables {
|
|
PORT;
|
|
NODE_ENV;
|
|
DB_URL;
|
|
DB_SSL;
|
|
REDIS_URL;
|
|
JWT_SECRET;
|
|
JWT_ACCESS_TTL;
|
|
JWT_REFRESH_TTL;
|
|
SMS_API_KEY;
|
|
SMS_WSDL_URL;
|
|
SMS_USERNAME;
|
|
SMS_PASSWORD;
|
|
SMS_NUMBER;
|
|
OTP_TTL_SECONDS;
|
|
MINIO_ENDPOINT;
|
|
MINIO_PORT;
|
|
MINIO_USE_SSL;
|
|
MINIO_ACCESS_KEY;
|
|
MINIO_SECRET_KEY;
|
|
MINIO_BUCKET;
|
|
MINIO_PUBLIC_BUCKET;
|
|
MINIO_PRIVATE_BUCKET;
|
|
MINIO_PUBLIC_URL;
|
|
}
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsNumberString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "PORT", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "NODE_ENV", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsNotEmpty)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "DB_URL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "DB_SSL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "REDIS_URL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsNotEmpty)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "JWT_SECRET", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "JWT_ACCESS_TTL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "JWT_REFRESH_TTL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsNotEmpty)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "SMS_API_KEY", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "SMS_WSDL_URL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "SMS_USERNAME", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "SMS_PASSWORD", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "SMS_NUMBER", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsNumberString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "OTP_TTL_SECONDS", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_ENDPOINT", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsNumberString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_PORT", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_USE_SSL", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_ACCESS_KEY", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_SECRET_KEY", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_BUCKET", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_PUBLIC_BUCKET", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_PRIVATE_BUCKET", void 0);
|
|
__decorate([
|
|
(0, class_validator_1.IsOptional)(),
|
|
(0, class_validator_1.IsString)(),
|
|
__metadata("design:type", String)
|
|
], EnvironmentVariables.prototype, "MINIO_PUBLIC_URL", void 0);
|
|
function validateEnv(config) {
|
|
const validatedConfig = (0, class_transformer_1.plainToInstance)(EnvironmentVariables, config, {
|
|
enableImplicitConversion: true,
|
|
});
|
|
const errors = (0, class_validator_1.validateSync)(validatedConfig, {
|
|
skipMissingProperties: false,
|
|
});
|
|
if (errors.length > 0) {
|
|
throw new Error(errors.toString());
|
|
}
|
|
return validatedConfig;
|
|
}
|
|
//# sourceMappingURL=env.validation.js.map
|