Skip to content

Commit

Permalink
Merge pull request #102 from boostcampwm-2024/feat/#77/init-swagger
Browse files Browse the repository at this point in the history
[Feat] swagger 세팅
  • Loading branch information
begong313 authored Nov 5, 2024
2 parents 8584d8a + d506ce1 commit 8a5f033
Show file tree
Hide file tree
Showing 4 changed files with 100 additions and 12 deletions.
13 changes: 7 additions & 6 deletions apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,18 @@
"@nestjs/common": "^10.0.0",
"@nestjs/core": "^10.0.0",
"@nestjs/platform-express": "^10.0.0",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1",
"@nestjs/swagger": "^8.0.1",
"@repo/shards": "workspace:*",
"@repo/types": "workspace:*"
"@repo/types": "workspace:*",
"reflect-metadata": "^0.2.0",
"rxjs": "^7.8.1"
},
"devDependencies": {
"@nestjs/cli": "^10.0.0",
"@nestjs/schematics": "^10.0.0",
"@nestjs/testing": "^10.0.0",
"@repo/lint": "workspace:*",
"@repo/tsconfig": "workspace:*",
"@types/express": "^5.0.0",
"@types/jest": "^29.5.2",
"@types/node": "^20.3.1",
Expand All @@ -49,9 +52,7 @@
"ts-loader": "^9.4.3",
"ts-node": "^10.9.1",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.1.3",
"@repo/lint": "workspace:*",
"@repo/tsconfig": "workspace:*"
"typescript": "^5.1.3"
},
"jest": {
"moduleFileExtensions": [
Expand Down
3 changes: 3 additions & 0 deletions apps/api/src/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Controller, Get } from '@nestjs/common';
import { ApiOperation, ApiResponse } from '@nestjs/swagger';

import { AppService } from './app.service';

Expand All @@ -7,6 +8,8 @@ export class AppController {
constructor(private readonly appService: AppService) {}

@Get()
@ApiOperation({ summary: 'swaggerTest' })
@ApiResponse({ status: 200, description: '기본 존재하는 api Test.' })
getHello(): string {
return this.appService.getHello();
}
Expand Down
12 changes: 11 additions & 1 deletion apps/api/src/main.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,21 @@
import { NestFactory } from '@nestjs/core';
import { DocumentBuilder, SwaggerModule } from '@nestjs/swagger';

import { AppModule } from '@/app.module';

async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.setGlobalPrefix('api');

//swagger setting
const config = new DocumentBuilder()
.setTitle('Ticle API server')
.setDescription('API 서버의 api 문서입니다.')
.setVersion('1.0')
.build();
const document = SwaggerModule.createDocument(app, config);
SwaggerModule.setup('api-doc', app, document);

app.setGlobalPrefix('api');
await app.listen(process.env.PORT ?? 3000);
}
bootstrap();
84 changes: 79 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 8a5f033

Please sign in to comment.