Skip to content
Snippets Groups Projects
game.controller.ts 792 B
Newer Older
L4168's avatar
L4168 committed
import { Controller, Post, UseGuards, Body, Get, Param } from '@nestjs/common';
import { GameService } from './game.service';
L4168's avatar
L4168 committed
import { AuthGuard } from '../shared/auth.guard';
import { User } from 'src/user/user.decorator';
import { GameDTO, FactionDTO } from './game.dto';

@Controller('game')
export class GameController {
L4168's avatar
L4168 committed
    constructor(private gameservice: GameService) { }

    @Post('new')
    @UseGuards(new AuthGuard())
    async newGame(@User('id') person, @Body() body) {
        return this.gameservice.createNewGame(person, body, body.factions);
    }

    @Get('listgames')
    async listGames() {
        return this.gameservice.listGames();
    }
L4168's avatar
L4168 committed

    @Get(':id')
    async returnGameInfo(@Param('id') id: string) {
        return this.gameservice.returnGameInfo(id);
    }