mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-01-20 01:34:47 +00:00
Enable swagger
This commit is contained in:
parent
75f6e64a1f
commit
a1b2f2cd78
|
|
@ -1,8 +1,12 @@
|
|||
{
|
||||
"name": "api",
|
||||
"name": "playt2-stats-api",
|
||||
"version": "0.0.1",
|
||||
"description": "",
|
||||
"author": "",
|
||||
"description": "Open-API powering stats.playt2.com",
|
||||
"authors": {
|
||||
"name": "Anthony Mineo",
|
||||
"email": "anthonymineo@gmail.com",
|
||||
"url": "https://anthonymineo.com"
|
||||
},
|
||||
"private": true,
|
||||
"license": "UNLICENSED",
|
||||
"scripts": {
|
||||
|
|
|
|||
|
|
@ -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…
Reference in a new issue