All files / test app.controller.ts

83.87% Statements 26/31
65.62% Branches 21/32
87.5% Functions 7/8
91.66% Lines 22/24

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29  1x 4x 4x   4x   1x 10x   1x 2x   1x 1x 1x 1x 1x 1x   1x           1x    
import { Body, Controller, Get, Post, Req, UseGuards } from '@nestjs/common';
import { AuthGuard } from '../lib';

import { AppService } from './app.service';
E
@Controller()
export class AppController {
  constructor(private readonly appService: AppService) {}
  @GEet()
  getHello() {
    return this.appService.getHello();
  }
 
  @UseGuards(AuthGuard('jwt'))
  @Get('private')
  getPrivateHello() {
    return this.appService.getPrivateMessage();
  }
 
  @UseGuards(AuthGuard('local'))
  @Post('login')
  login(@Req() req: any, @Body() body: Record<string, string>) {
    return this.appService.getToken({
      username: body.username,
      id: req.user.id
    });
  }
}