| Total Complexity | 2 |
| Complexity/F | 1 |
| Lines of Code | 42 |
| Function Count | 2 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { |
||
| 2 | Controller, |
||
| 3 | Get, |
||
| 4 | Inject, |
||
| 5 | Render, |
||
| 6 | Res, |
||
| 7 | UseGuards |
||
| 8 | } from '@nestjs/common'; |
||
| 9 | import { Response } from 'express'; |
||
| 10 | import { GetPendingLeaveRequestsCountQuery } from 'src/Application/HumanResource/Leave/Query/GetPendingLeaveRequestsCountQuery'; |
||
| 11 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
| 12 | import { RouteNameResolver } from 'src/Infrastructure/Common/ExtendedRouting/RouteNameResolver'; |
||
| 13 | import { WithName } from 'src/Infrastructure/Common/ExtendedRouting/WithName'; |
||
| 14 | import { IsAuthenticatedGuard } from 'src/Infrastructure/HumanResource/User/Security/IsAuthenticatedGuard'; |
||
| 15 | |||
| 16 | @Controller() |
||
| 17 | @UseGuards(IsAuthenticatedGuard) |
||
| 18 | export class HomeController { |
||
| 19 | constructor( |
||
| 20 | private readonly resolver: RouteNameResolver, |
||
| 21 | @Inject('IQueryBus') |
||
| 22 | private readonly queryBus: IQueryBus |
||
| 23 | ) {} |
||
| 24 | |||
| 25 | @Get('app') |
||
| 26 | @WithName('home') |
||
| 27 | @Render('pages/home.njk') |
||
| 28 | public async get() { |
||
| 29 | const pendingLeaves = await this.queryBus.execute( |
||
| 30 | new GetPendingLeaveRequestsCountQuery() |
||
| 31 | ); |
||
| 32 | |||
| 33 | return { pendingLeaves }; |
||
| 34 | } |
||
| 35 | |||
| 36 | @Get() |
||
| 37 | @WithName('index') |
||
| 38 | public index(@Res() res: Response) { |
||
| 39 | res.redirect(303, this.resolver.resolve('home')); |
||
| 40 | } |
||
| 41 | } |
||
| 42 |