This commit is contained in:
Николай Вигдоров
2025-03-07 00:30:49 +03:00
parent 6121847fe3
commit 3e7a847c5a
3 changed files with 38 additions and 23 deletions

View File

@ -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'];

View File

@ -1,26 +1,28 @@
import {NestFactory} from '@nestjs/core';
import {SwaggerModule, DocumentBuilder} from '@nestjs/swagger';
import {AppModule} from './app.module';
import {APP_CONTROLLER} from './consts';
import { NestFactory } from '@nestjs/core';
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
import { AppModule } from './app.module';
import { APP_CONTROLLER, APP_PORT } from './consts';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
const app = await NestFactory.create(AppModule);
const options = new DocumentBuilder()
.addSecurity('apiKey', {
type: 'apiKey',
in: 'header',
name: 'Authorization',
})
.setTitle('Image API')
.setDescription('API для работы с картинками')
.setVersion('1.0.0')
.addTag(APP_CONTROLLER)
.build();
const options = new DocumentBuilder()
.addSecurity('apiKey', {
type: 'apiKey',
in: 'header',
name: 'Authorization',
})
.setTitle('Image API')
.setDescription('API для работы с картинками')
.setVersion('1.0.0')
.addTag(APP_CONTROLLER)
.build();
const document = SwaggerModule.createDocument(app, options);
SwaggerModule.setup('api', app, document);
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();