|
|
|
## GAME
|
|
|
|
|
|
|
|
Game-folder follows the usual logic containing a controller, a service, a DTO and an entity file.
|
|
|
|
|
|
|
|
## game.controller.ts
|
|
|
|
|
|
|
|
Contains 13 routes, which are all prefixed with url `game`.
|
|
|
|
|
|
|
|
Uses some decorators as explained in the [User](user) page, but it also has some new faces:
|
|
|
|
|
|
|
|
`@Roles('gameperson-role')` validates the user's role from the token. Returns 403 Unauthorized, if the user does not match the requirements. The decorator needs the game's UUID as a parameter in the URL. Stored in the `shared` folder.
|
|
|
|
|
|
|
|
`@GameStates('CREATED')` validates the game's current state. Returns 403 Unauthorized, if the game's state does not match the criteria. This decorator also needs the game's UUID as a parameter in the URL. Stored in the `shated` folder.
|
|
|
|
|
|
|
|
### create a new game, POST /game/new
|
|
|
|
|
|
|
|
- Body must contain a newGameDTO JSON-object as specified in `game.dto.ts`:
|
|
|
|
|
|
|
|
```
|
|
|
|
{
|
|
|
|
name: string;
|
|
|
|
desc: string;
|
|
|
|
center: {
|
|
|
|
lat: number;
|
|
|
|
lng: number;
|
|
|
|
}
|
|
|
|
startdate: string;
|
|
|
|
enddate: string;
|
|
|
|
image: string;
|
|
|
|
}
|
|
|
|
```
|
|
|
|
|
|
|
|
- `name` is limited between 3 and 31 characters
|
|
|
|
|
|
|
|
- `desc` is limited between 1 and 255 characters
|
|
|
|
|
|
|
|
- `center` is an object, which contains the latlng pair
|
|
|
|
|
|
|
|
- `startdate` and `enddate` must be valid Date String
|
|
|
|
|
|
|
|
- `image` is the path to the image and is limited to 65 characters
|
|
|
|
|
|
|
|
### moti loppu |