Newer
Older
import {
Controller,
Post,
UseGuards,
Body,
Get,
Param,
UsePipes,
Put,
} from '@nestjs/common';
import { GameService } from './game.service';
import { User } from '../user/user.decorator';
import { GameDTO } from './game.dto';
import { ValidationPipe } from '../shared/validation.pipe';
import { Game_PersonEntity } from './game.entity';
import { Roles } from '../shared/roles.decorator';
@Controller('game')
export class GameController {
@Post('new')
@UseGuards(new AuthGuard())
//@UsePipes(new ValidationPipe())
async newGame(@User('id') person, @Body() body: GameDTO) {
return this.gameservice.createNewGame(person, body);
}
@Put(':id')
@Roles('admin')
@UseGuards(new AuthGuard())
@UsePipes(new ValidationPipe())
async editGame(@Param('id') id: string, @Body() body: GameDTO) {
return this.gameservice.editGame(id, body);
}
// @UseGuards(new AuthGuard())
// @UsePipes(new ValidationPipe())
// @Post(':id')
// async joinGame(@User('id') person, @Body() data: Game_PersonEntity) {
// try {
// return this.gameservice.joinGame(person, data, json);
// } catch (error) {}
// }
@Put('joinfaction')
@UseGuards(new AuthGuard())
joinFaction(
@User('id') person,
@Param('id') gameId,
@Param('faction') faction: string,
@Body() password: string,
) {
try {
// return this.gameservice.joinFaction(person, gameId, faction, password);
} catch (error) {
return error;
@Get('listgames')
async listGames() {
return this.gameservice.listGames();
}
@Get(':id')
async returnGameInfo(@Param('id') id: string) {
return this.gameservice.returnGameInfo(id);
}