-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.ts
More file actions
46 lines (38 loc) · 1.25 KB
/
main.ts
File metadata and controls
46 lines (38 loc) · 1.25 KB
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
40
41
42
43
44
45
46
import { ClassSerializerInterceptor, ValidationPipe } from '@nestjs/common';
import { NestFactory, Reflector } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
import { AppModule } from './app.module';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.useGlobalPipes(
new ValidationPipe({
transform: true,
transformOptions: {
enableImplicitConversion: true,
},
disableErrorMessages: process.env.NODE_ENV === 'prod',
whitelist: true,
}),
);
app.useGlobalInterceptors(new ClassSerializerInterceptor(app.get(Reflector)));
const config = new DocumentBuilder()
.setTitle('EVNotify API')
.setDescription('Documentation for EVNotify API')
.setVersion('3.0')
.addApiKey(
{
type: 'apiKey',
name: 'Authorization',
in: 'header',
description:
'Enter your authorization string in the format: <your-akey> <your-api-token>, e.g. "123456 8c6a51c82307e2b4df0c"',
},
'custom-auth',
)
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('/', app, document);
app.enableCors();
await app.listen(process.env.SERVER_PORT);
}
bootstrap();