1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40import { NestFactory } from '@nestjs/core';
import { AppModule } from './app.module';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import cookieParser from 'cookie-parser';
import { HttpExceptionFilter } from './common/exceptions/http-exception.filter';
declare const module: any;
async function bootstrap() {
const app = await NestFactory.create(AppModule);
// app.enableCors({
// origin: true,
// credentials: true,
// });
app.useGlobalFilters(new HttpExceptionFilter());
app.use(cookieParser());
// μ€μ¨κ±° λͺ¨λ
const config = new DocumentBuilder()
.setTitle('shop API')
.setDescription('shop κ°λ°μ μν API λ¬Έμ')
.setVersion('1.0')
.addCookieAuth('connect.sid')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('docs', app, document);
const port = process.env.PORT || 3000;
await app.listen(port);
console.log(`listening on port ${port}`);
// hot-reload
if (module.hot) {
module.hot.accept();
module.hot.dispose(() => app.close());
}
}
bootstrap();