Skip to content
Snippets Groups Projects

Gamecreation

Merged Ghost User requested to merge gamecreation into Development
8 files
+ 119
25
Compare changes
  • Side-by-side
  • Inline
Files
8
+ 36
0
 
import { Controller, Post, UseGuards, Body, Get, Param, UsePipes } from '@nestjs/common';
 
 
import { GameService } from './game.service';
 
import { AuthGuard } from '../shared/auth.guard';
 
import { User } from '../user/user.decorator';
 
import { GameDTO } from './game.dto';
 
import { ValidationPipe } from '../shared/validation.pipe';
 
 
@Controller('game')
 
export class GameController {
 
constructor(private gameservice: GameService) { }
 
 
@Post('new')
 
@UseGuards(new AuthGuard())
 
@UsePipes(new ValidationPipe())
 
async newGame(@User('id') person, @Body() body: GameDTO ) {
 
return this.gameservice.createNewGame(person, body);
 
}
 
 
@UseGuards(new AuthGuard())
 
@UsePipes(new ValidationPipe())
 
@Post(':id')
 
async joinGame(@User('id') person, @Param('id') id: string, @Body() password: string) {
 
return this.gameservice.joinGame(person, id, password);
 
}
 
 
@Get('listgames')
 
async listGames() {
 
return this.gameservice.listGames();
 
}
 
 
@Get(':id')
 
async returnGameInfo(@Param('id') id: string) {
 
return this.gameservice.returnGameInfo(id);
 
}
 
}
Loading