Completed
Push — master ( 7c7ab7...45cb8f )
by Mathieu
19s queued 11s
created

server/src/Infrastructure/HumanResource/User/Action/GetMeAction.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 25
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 21
mnd 0
bc 0
fnc 1
dl 0
loc 25
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A GetMeAction.index 0 9 1
1
import {Controller, Get, UseGuards} from '@nestjs/common';
2
import {AuthGuard} from '@nestjs/passport';
3
import {ApiUseTags, ApiOperation, ApiBearerAuth} from '@nestjs/swagger';
4
import {LoggedUser} from '../Decorator/LoggedUser';
5
import {User} from 'src/Domain/HumanResource/User/User.entity';
6
import {UserView} from 'src/Application/HumanResource/User/View/UserView';
7
8
@Controller('users')
9
@ApiUseTags('User')
10
@ApiBearerAuth()
11
@UseGuards(AuthGuard('bearer'))
12
export class GetMeAction {
13
  @Get('me')
14
  @ApiOperation({title: 'Get current user'})
15
  public async index(@LoggedUser() user: User): Promise<UserView> {
16
    return new UserView(
17
      user.getId(),
18
      user.getFirstName(),
19
      user.getLastName(),
20
      user.getEmail(),
21
      user.getRole()
22
    );
23
  }
24
}
25