backend/src/auth/auth.controller.ts   A
last analyzed

Complexity

Total Complexity 3
Complexity/F 1

Size

Lines of Code 37
Function Count 3

Duplication

Duplicated Lines 0
Ratio 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 32
dl 0
loc 37
ccs 13
cts 13
cp 1
rs 10
c 0
b 0
f 0
wmc 3
mnd 0
bc 0
fnc 3
bpm 0
cpm 1
noi 0

3 Functions

Rating   Name   Duplication   Size   Complexity  
A AuthController.getMe 0 8 1
A AuthController.exchangeToken 0 6 1
A AuthController.getStatus 0 8 1
1 8
import { Controller, Post, Body, Get, UseGuards, Req } from '@nestjs/common';
2 8
import { AuthService } from './auth.service';
3 8
import { JwtAuthGuard } from './guards/jwt-auth.guard';
4 8
import { TokenExchangeDto } from './dto/token-exchange.dto/token-exchange.dto';
5 8
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth } from '@nestjs/swagger';
6
7
@ApiTags('auth')
8
@Controller({ path: 'auth', version: '1' })
9 8
export class AuthController {
10 11
  constructor(private readonly authService: AuthService) {}
11
12
  @Post('token')
13
  @ApiOperation({ summary: 'Exchange GitHub code for access token' })
14
  @ApiResponse({ status: 200, description: 'Token exchange successful' })
15 8
  async exchangeToken(@Body() tokenExchangeDto: TokenExchangeDto) {
16 2
    return this.authService.exchangeGithubCode(tokenExchangeDto.code);
17
  }
18
19
  @Get('me')
20
  @UseGuards(JwtAuthGuard)
21
  @ApiBearerAuth()
22
  @ApiOperation({ summary: 'Get current user information' })
23
  @ApiResponse({ status: 200, description: 'Returns user information' })
24 8
  async getMe(@Req() req) {
25 1
    return req.user;
26
  }
27
28
  @Get('status')
29
  @UseGuards(JwtAuthGuard)
30
  @ApiBearerAuth()
31
  @ApiOperation({ summary: 'Check authentication status' })
32
  @ApiResponse({ status: 200, description: 'Returns authentication status' })
33 8
  async getStatus(@Req() req) {
34 1
    return this.authService.getStatus(req.user);
35
  }
36
}
37