add env
This commit is contained in:
@ -14,6 +14,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/image-back:0.0.1-amd64 .",
|
||||
"_example_imagePush": "docker push vigdorov/image-back:0.0.1-amd64",
|
||||
"test": "jest",
|
||||
"test:watch": "jest --watch",
|
||||
"test:cov": "jest --coverage",
|
||||
|
||||
@ -1,11 +1,22 @@
|
||||
export const MONGO_URL = 'mongodb://localhost:27017';
|
||||
// Подключение к MongoDB
|
||||
export const MONGO_URL = process.env.MONGODB_URI || 'mongodb://localhost:27017';
|
||||
|
||||
export const DB_AUTHORS = 'image-back-authors';
|
||||
export const DB_IMAGES = 'image-back-images';
|
||||
// Имя базы данных для пользователей и хранилищ
|
||||
export const DB_AUTHORS = process.env.DB_AUTHORS || 'image-back-authors';
|
||||
export const DB_IMAGES = process.env.DB_IMAGES || 'image-back-images';
|
||||
|
||||
// Порт приложения
|
||||
export const APP_PORT = parseInt(process.env.APP_PORT || '3000', 10);
|
||||
|
||||
// Другие константы
|
||||
export const APP_CONTROLLER = 'image-app';
|
||||
|
||||
export const ALLOW_ORIGIN_ALL: [string, string] = ['Access-Control-Allow-Origin', '*'];
|
||||
// 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', 'true'];
|
||||
export const CONTENT_LENGTH: [string, string] = ['Content-Length', '0'];
|
||||
export const ALLOW_METHOD: [string, string] = ['Access-Control-Allow-Methods', 'GET,HEAD,PUT,PATCH,POST,DELETE'];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
import { NestFactory } from '@nestjs/core';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import { AppModule } from './app.module';
|
||||
import {APP_CONTROLLER} from './consts';
|
||||
import { APP_CONTROLLER, APP_PORT } from './consts';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
@ -21,6 +21,8 @@ async function bootstrap() {
|
||||
const document = SwaggerModule.createDocument(app, options);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
|
||||
await app.listen(3000);
|
||||
console.log(`Application is starting on port ${APP_PORT}`);
|
||||
|
||||
await app.listen(APP_PORT);
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user