| ... | ... | @@ -158,6 +158,23 @@ GameService uses the NotificationGateway to send socket updates for users. More |
|
|
|
|
|
|
|
- Triggers a socket update for flagbox-event, which triggers a fetch in frontend
|
|
|
|
|
|
|
|
## gameperson.entity.ts
|
|
|
|
|
|
|
|
Reflects the datababse table for games, gameperson, objectivepoints and their history.
|
|
|
|
|
|
|
|
You can define some default settings in the Entity's constructor, like we do in Game_PersonEntity:
|
|
|
|
|
|
|
|
```
|
|
|
|
@Entity('Game_Person', {
|
|
|
|
orderBy: {
|
|
|
|
person: 'ASC',
|
|
|
|
},
|
|
|
|
})
|
|
|
|
export class Game_PersonEntity {}
|
|
|
|
```
|
|
|
|
|
|
|
|
This way, when finding all game_persons with TypeORM's `find` method, they are sorted by the person column as default
|
|
|
|
|
|
|
|
## gameperson.decorator.ts
|
|
|
|
|
|
|
|
Gameperson decorators works exactly like [UserDecorator](./user#userdecoratorts), but retuns information on user's role in the game. For the decorator to work, the controller **needs** the `RolesGuard` decorator as shown in the example below:
|
| ... | ... | @@ -165,7 +182,7 @@ Gameperson decorators works exactly like [UserDecorator](./user#userdecoratorts) |
|
|
|
```typescript
|
|
|
|
@Post('example')
|
|
|
|
@Roles('admin)
|
|
|
|
async exampleroute(@GamePerson() gamePerson: Game_PersonEntity, @Body() data) {
|
|
|
|
async exampleroute(@GamePerson() gamePerson, @Body() data) {
|
|
|
|
return this.exampleservice.examplefunction(gamePerson, body);
|
|
|
|
}
|
|
|
|
``` |