mirror of
https://github.com/amineo/t2-stat-parser.git
synced 2026-07-15 00:04:35 +00:00
Enable swagger
This commit is contained in:
parent
75f6e64a1f
commit
a1b2f2cd78
4 changed files with 25 additions and 5 deletions
|
|
@ -1,8 +1,12 @@
|
||||||
{
|
{
|
||||||
"name": "api",
|
"name": "playt2-stats-api",
|
||||||
"version": "0.0.1",
|
"version": "0.0.1",
|
||||||
"description": "",
|
"description": "Open-API powering stats.playt2.com",
|
||||||
"author": "",
|
"authors": {
|
||||||
|
"name": "Anthony Mineo",
|
||||||
|
"email": "anthonymineo@gmail.com",
|
||||||
|
"url": "https://anthonymineo.com"
|
||||||
|
},
|
||||||
"private": true,
|
"private": true,
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
|
|
@ -75,4 +79,4 @@
|
||||||
"coverageDirectory": "../coverage",
|
"coverageDirectory": "../coverage",
|
||||||
"testEnvironment": "node"
|
"testEnvironment": "node"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,4 +1,6 @@
|
||||||
import { Controller, Get, Param } from '@nestjs/common';
|
import { Controller, Get, Param } from '@nestjs/common';
|
||||||
|
import { ApiOperation } from '@nestjs/swagger';
|
||||||
|
|
||||||
import { GameService } from './game.service';
|
import { GameService } from './game.service';
|
||||||
|
|
||||||
@Controller('game')
|
@Controller('game')
|
||||||
|
|
@ -7,6 +9,7 @@ export class GameController {
|
||||||
|
|
||||||
// /games/:gameId
|
// /games/:gameId
|
||||||
@Get(':gameId')
|
@Get(':gameId')
|
||||||
|
@ApiOperation({ summary: 'Find game by Id' })
|
||||||
findOne(@Param('gameId') gameId: string) {
|
findOne(@Param('gameId') gameId: string) {
|
||||||
return this.gameService.findOne(gameId);
|
return this.gameService.findOne(gameId);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -20,7 +20,8 @@ export class GameService {
|
||||||
relations: [ 'game', 'playerGuid' ],
|
relations: [ 'game', 'playerGuid' ],
|
||||||
where: [ { game: { gameId: gameId } } ]
|
where: [ { game: { gameId: gameId } } ]
|
||||||
});
|
});
|
||||||
if (!query) {
|
|
||||||
|
if (!query.length) {
|
||||||
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
throw new NotFoundException(`Game ID: ${gameId} not found`);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,7 @@
|
||||||
import { NestFactory } from '@nestjs/core';
|
import { NestFactory } from '@nestjs/core';
|
||||||
import { ValidationPipe } from '@nestjs/common';
|
import { ValidationPipe } from '@nestjs/common';
|
||||||
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
|
|
||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
|
|
||||||
async function bootstrap() {
|
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);
|
await app.listen(3000);
|
||||||
}
|
}
|
||||||
bootstrap();
|
bootstrap();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue