37 lines
946 B
TypeScript
37 lines
946 B
TypeScript
import { NestFactory } from '@nestjs/core';
|
|
import { AppModule } from './app.module';
|
|
import { HttpService } from '@nestjs/axios';
|
|
import { HttpExceptionFilter } from './filters/http-exception.filter';
|
|
import { InternalServerErrorException } from '@nestjs/common';
|
|
import * as session from 'express-session';
|
|
|
|
async function bootstrap() {
|
|
const httpService = new HttpService();
|
|
const app = await NestFactory.create(AppModule);
|
|
|
|
app.enableCors();
|
|
app.setGlobalPrefix('api');
|
|
app.useGlobalFilters(new HttpExceptionFilter());
|
|
app.use(
|
|
session({
|
|
secret: process.env.SESSION_SECRET,
|
|
resave: false,
|
|
saveUninitialized: false
|
|
})
|
|
)
|
|
|
|
httpService.axiosRef.interceptors.response.use(
|
|
(response) => {
|
|
return response;
|
|
},
|
|
(error) => {
|
|
console.error('Internal server error exception', error);
|
|
|
|
throw new InternalServerErrorException();
|
|
}
|
|
);
|
|
|
|
await app.listen(3000);
|
|
}
|
|
bootstrap();
|