-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
5f167f1
commit 7b264f3
Showing
8 changed files
with
120 additions
and
6 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,38 @@ | ||
import { ValidationPipe } from '@nestjs/common'; | ||
import { NestFactory } from '@nestjs/core'; | ||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger'; | ||
import { AppModule } from './app.module'; | ||
|
||
async function bootstrap() { | ||
const app = await NestFactory.create(AppModule); | ||
|
||
app.useGlobalPipes( | ||
new ValidationPipe({ | ||
whitelist: true, | ||
}), | ||
); | ||
|
||
const config = new DocumentBuilder() | ||
.setTitle('To-do List') | ||
.setDescription('A ToDoList API description') | ||
.setVersion('1.0') | ||
.addTag('todolist') | ||
.addBearerAuth( | ||
{ | ||
// I was also testing it without prefix 'Bearer ' before the JWT | ||
description: `Please enter token in following format: Bearer <JWT>`, | ||
name: 'Authorization', | ||
bearerFormat: 'Bearer', // I`ve tested not to use this field, but the result was the same | ||
scheme: 'Bearer', | ||
type: 'http', // I`ve attempted type: 'apiKey' too | ||
in: 'Header', | ||
}, | ||
'access-token', // This name here is important for matching up with @ApiBearerAuth() in your controller! | ||
) | ||
.build(); | ||
const document = SwaggerModule.createDocument(app, config); | ||
SwaggerModule.setup('api', app, document); | ||
|
||
await app.listen(process.env.PORT || 3000); | ||
} | ||
bootstrap(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters