diff --git a/package.json b/package.json index 16ac086..3449cb1 100644 --- a/package.json +++ b/package.json @@ -13,6 +13,8 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "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:watch": "jest --watch", "test:cov": "jest --coverage", diff --git a/src/consts.ts b/src/consts.ts index 40721d8..6e9f302 100644 --- a/src/consts.ts +++ b/src/consts.ts @@ -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', diff --git a/src/main.ts b/src/main.ts index 87c91f9..bb1157c 100644 --- a/src/main.ts +++ b/src/main.ts @@ -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();