mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-03-05 04:30:21 +00:00
Enable swagger
This commit is contained in:
parent
75f6e64a1f
commit
a1b2f2cd78
4 changed files with 25 additions and 5 deletions
|
|
@ -1,4 +1,6 @@
|
|||
import { Controller, Get, Param } from '@nestjs/common';
|
||||
import { ApiOperation } from '@nestjs/swagger';
|
||||
|
||||
import { GameService } from './game.service';
|
||||
|
||||
@Controller('game')
|
||||
|
|
@ -7,6 +9,7 @@ export class GameController {
|
|||
|
||||
// /games/:gameId
|
||||
@Get(':gameId')
|
||||
@ApiOperation({ summary: 'Find game by Id' })
|
||||
findOne(@Param('gameId') gameId: string) {
|
||||
return this.gameService.findOne(gameId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,7 +20,8 @@ export class GameService {
|
|||
relations: [ 'game', 'playerGuid' ],
|
||||
where: [ { game: { gameId: gameId } } ]
|
||||
});
|
||||
if (!query) {
|
||||
|
||||
if (!query.length) {
|
||||
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
import { NestFactory } from '@nestjs/core';
|
||||
import { ValidationPipe } from '@nestjs/common';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
|
||||
import { AppModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
|
|
@ -16,6 +18,16 @@ async function bootstrap() {
|
|||
})
|
||||
);
|
||||
|
||||
const swaggerOptions = new DocumentBuilder()
|
||||
.setTitle('Tribes 2 Stats API')
|
||||
.setDescription('Powering stats.playt2.com')
|
||||
.setVersion('1.0')
|
||||
.addTag('task')
|
||||
.build();
|
||||
|
||||
const document = SwaggerModule.createDocument(app, swaggerOptions);
|
||||
SwaggerModule.setup('api', app, document);
|
||||
|
||||
await app.listen(3000);
|
||||
}
|
||||
bootstrap();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue