import { Controller, Put, UseGuards, Get, Param, UsePipes, ValidationPipe, Body, } from '@nestjs/common'; import { AuthGuard } from 'src/shared/auth.guard'; import { DrawService } from './draw.service'; import { MapDrawingDTO } from './mapdrawing.dto'; import { Roles } from 'src/shared/roles.decorator'; import { User } from 'src/user/user.decorator'; import { FactionDTO } from 'src/game/game.dto'; import { FactionEntity } from 'src/game/faction.entity'; /* DrawController Functions either insert or return MapDrawing data, Insert functions require user to have proper role (either gm or commander) in the game to be able store the ddata: MapDrawingDTOata to database. Data return functions require atleast spectator role. */ @Controller('draw') export class DrawController { constructor(private drawService: DrawService) {} @Put() @UseGuards(new AuthGuard()) @UsePipes(new ValidationPipe()) async draw(@Body() data: MapDrawingDTO) { try { return this.drawService.draw(data); } catch (error) { return error.message; } } @Get(':id') @UseGuards(new AuthGuard()) @UsePipes(new ValidationPipe()) async drawMap(@Param('id') id: string, @Body() faction: FactionDTO) { try { return this.drawService.drawMap(id, faction); } catch (error) { return error.message; } } }