Skip to content

Commit ce86fd1

Browse files
committed
docs: adding nestjs swagger integration into back-end to api documentation
1 parent 38b9b7a commit ce86fd1

File tree

3 files changed

+67
-2
lines changed

3 files changed

+67
-2
lines changed

backend/package-lock.json

Lines changed: 56 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

backend/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
"@nestjs/mapped-types": "*",
2828
"@nestjs/passport": "^11.0.5",
2929
"@nestjs/platform-express": "^11.0.1",
30+
"@nestjs/swagger": "^11.2.0",
3031
"@prisma/client": "^6.16.3",
3132
"bcrypt": "^6.0.0",
3233
"class-transformer": "^0.5.1",

backend/src/main.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,19 @@
11
import { NestFactory } from '@nestjs/core';
22
import { AppModule } from './app.module';
33
import { ValidationPipe } from '@nestjs/common';
4+
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';
45

56
async function bootstrap() {
67
const app = await NestFactory.create(AppModule);
8+
const config = new DocumentBuilder()
9+
.setTitle('Fullstack Challenge')
10+
.setDescription('Time Tracker API documentation')
11+
.setVersion('1.0')
12+
.addTag('time-tracker')
13+
.build();
14+
const documentFactory = () => SwaggerModule.createDocument(app, config);
15+
SwaggerModule.setup('api', app, documentFactory);
16+
717
app.enableCors();
818
app.useGlobalPipes(new ValidationPipe({ whitelist: true }));
919
await app.listen(process.env.PORT ?? 3000);

0 commit comments

Comments
 (0)