Newer
Older
import {
Controller,
Post,
Param,
UseGuards,
UsePipes,
Body,
} from '@nestjs/common';
import { TrackingService } from './tracking.service';
import { User } from '../user/user.decorator';
import { Roles, GameStates } from '../shared/guard.decorator';
import { ValidationPipe } from '../shared/validation.pipe';
import { GeoDTO } from './geo.dto';
import { GamePerson } from 'src/game/gameperson.decorator';
@Controller('tracking')
export class TrackingController {
constructor(private trackingservice: TrackingService) {}
// inserts tracking data to the database
// :id is the id of the game
@Post('location/:id')
@Roles('soldier')
return this.trackingservice.trackLocation(gameperson, id, trackdata);
@Get('players/:id')
@Roles('admin', 'factionleader')
@GameStates('STARTED', 'PAUSED')
async getPlayerLocations(@GamePerson() gameperson, @Param('id') gameId) {
return this.trackingservice.getPlayers(gameperson, gameId);
@Get('player/:id')
@Roles('admin', 'factionleader')
@GameStates('STARTED', 'PAUSED')
@UseInterceptors(ClassSerializerInterceptor)
async getPlayerData(@User('id') userId, @Param('id') gameid, @Body() person) {
return this.trackingservice.getPlayerData(person);
}