24 lines
632 B
TypeScript
24 lines
632 B
TypeScript
|
|
import 'reflect-metadata';
|
||
|
|
import { Logger } from '@nestjs/common';
|
||
|
|
import { NestFactory } from '@nestjs/core';
|
||
|
|
import { AppModule } from './app.module';
|
||
|
|
import { loadEnv } from './infra/config/load-env';
|
||
|
|
|
||
|
|
async function bootstrap() {
|
||
|
|
loadEnv();
|
||
|
|
|
||
|
|
const app = await NestFactory.create(AppModule);
|
||
|
|
const frontendUrl = process.env.FRONTEND_URL || 'http://localhost:3000';
|
||
|
|
const port = Number(process.env.PORT || process.env.BACKEND_PORT || 3001);
|
||
|
|
|
||
|
|
app.enableCors({
|
||
|
|
origin: frontendUrl,
|
||
|
|
credentials: true,
|
||
|
|
});
|
||
|
|
|
||
|
|
await app.listen(port);
|
||
|
|
Logger.log(`Backend ouvindo na porta ${port}`, 'Bootstrap');
|
||
|
|
}
|
||
|
|
|
||
|
|
bootstrap();
|