add env process

This commit is contained in:
Николай Вигдоров
2025-03-06 22:04:07 +03:00
parent 1c3dc15c52
commit c72a21db4a
3 changed files with 17 additions and 7 deletions

View File

@ -13,6 +13,8 @@
"start:debug": "nest start --debug --watch", "start:debug": "nest start --debug --watch",
"start:prod": "node dist/main", "start:prod": "node dist/main",
"lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix",
"_example_imageBuild": "docker buildx build --platform linux/amd64 -t vigdorov/simple-storage:0.0.1-amd64",
"_example_imagePush": "docker push vigdorov/simple-storage:0.0.1-amd64",
"test": "jest", "test": "jest",
"test:watch": "jest --watch", "test:watch": "jest --watch",
"test:cov": "jest --coverage", "test:cov": "jest --coverage",

View File

@ -1,13 +1,20 @@
export const MONGO_URL = 'mongodb://localhost:27017'; // Подключение к MongoDB
export const MONGO_URL = process.env.MONGODB_URI || 'mongodb://localhost:27017';
// Имя базы данных для пользователей и хранилищ
export const DB_USERS = process.env.DB_USERS || 'storage-back-users';
export const DB_STORAGES = process.env.DB_STORAGES || 'storage-back-storages';
// Порт приложения
export const APP_PORT = parseInt(process.env.APP_PORT || '3000', 10);
// Другие константы
export const APP_CONTROLLER = 'storage-app'; export const APP_CONTROLLER = 'storage-app';
export const DB_USERS = 'storage-back-users'; // CORS настройки
export const DB_STORAGES = 'storage-back-storages';
export const ALLOW_ORIGIN_ALL: [string, string] = [ export const ALLOW_ORIGIN_ALL: [string, string] = [
'Access-Control-Allow-Origin', 'Access-Control-Allow-Origin',
'*', process.env.CORS_ORIGIN || '*',
]; ];
export const ALLOW_CREDENTIALS: [string, string] = [ export const ALLOW_CREDENTIALS: [string, string] = [
'Access-Control-Allow-Credentials', 'Access-Control-Allow-Credentials',

View File

@ -1,7 +1,7 @@
import { NestFactory } from '@nestjs/core'; import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module'; import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger'; import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { APP_CONTROLLER } from './consts'; import { APP_CONTROLLER, APP_PORT } from './consts';
async function bootstrap() { async function bootstrap() {
const app = await NestFactory.create(AppModule); const app = await NestFactory.create(AppModule);
@ -22,7 +22,8 @@ async function bootstrap() {
SwaggerModule.setup('api', app, document); SwaggerModule.setup('api', app, document);
await app.listen(4005); console.log(`Application is starting on port ${APP_PORT}`);
await app.listen(APP_PORT);
} }
void bootstrap(); void bootstrap();