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
import { Controller, Post, UseGuards, Body, Get, Param } from '@nestjs/common';
import { Controller, Post, UseGuards, Body, Get, Param, UsePipes } from '@nestjs/common';
 
import { GameService } from './game.service';
import { GameService } from './game.service';
import { AuthGuard } from '../shared/auth.guard';
import { AuthGuard } from '../shared/auth.guard';
import { User } from 'src/user/user.decorator';
import { User } from '../user/user.decorator';
import { GameDTO, FactionDTO } from './game.dto';
import { GameDTO } from './game.dto';
 
import { ValidationPipe } from '../shared/validation.pipe';
 
import { async } from 'rxjs/internal/scheduler/async';
@Controller('game')
@Controller('game')
export class GameController {
export class GameController {
@@ -10,8 +13,16 @@ export class GameController {
@@ -10,8 +13,16 @@ export class GameController {
@Post('new')
@Post('new')
@UseGuards(new AuthGuard())
@UseGuards(new AuthGuard())
async newGame(@User('id') person, @Body() body) {
@UsePipes(new ValidationPipe())
return this.gameservice.createNewGame(person, body, body.factions);
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')
@Get('listgames')
Loading