All files / src/modules/mortgages mortgages.controller.ts

100% Statements 23/23
75% Branches 3/4
100% Functions 7/7
100% Lines 15/15

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 30 31 3212x 12x 12x 12x     12x 12x 12x       12x 1x   12x 12x 12x   12x       12x       12x        
import { Body, Controller, Get, Param, ParseIntPipe, Post, Req, UseGuards } from '@nestjs/common';
import { MortgagesService } from '@app/modules/mortgages/mortgages.service';
import { JwtAuthGuard } from '@app/common/guards/jwt-auth.guard';
import { IsInt } from 'class-validator';
 
class MortgageCalcDto {
  @IsInt() amountCents!: number;
  @IsInt() termMonths!: number;
  @IsInt() aprBps!: number;
}
 
@Controller('mortgages')
export class MortgagesController {
  constructor(private readonly svc: MortgagesService) {}
 
  @Get('lenders') listLenders() { return this.svc.listLenders(); }
  @Get('products') listProducts() { return this.svc.listProducts(); }
  @Get('rates') listRates() { return this.svc.listRates(); }
 
  @Post('calc') calc(@Body() dto: MortgageCalcDto) { return this.svc.calc(dto); }
 
  @Post('apps')
  @UseGuards(JwtAuthGuard)
  startApp(@Req() req: any, @Body() body: any) { return this.svc.startApp(req.user.id, body); }
 
  @Get('apps/:id')
  @UseGuards(JwtAuthGuard)
  getApp(@Param('id', ParseIntPipe) id: number, @Req() req: any) { return this.svc.getApp(id, req.user.id); }
}