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

@ -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 DB_USERS = 'storage-back-users';
export const DB_STORAGES = 'storage-back-storages';
// CORS настройки
export const ALLOW_ORIGIN_ALL: [string, string] = [
'Access-Control-Allow-Origin',
'*',
process.env.CORS_ORIGIN || '*',
];
export const ALLOW_CREDENTIALS: [string, string] = [
'Access-Control-Allow-Credentials',

View File

@ -1,7 +1,7 @@
import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { APP_CONTROLLER } from './consts';
import { APP_CONTROLLER, APP_PORT } from './consts';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
@ -22,7 +22,8 @@ async function bootstrap() {
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();