Total Complexity | 2 |
Complexity/F | 2 |
Lines of Code | 36 |
Function Count | 1 |
Duplicated Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | import { |
||
2 | Controller, |
||
3 | Inject, |
||
4 | BadRequestException, |
||
5 | UseGuards, |
||
6 | Param, |
||
7 | Get |
||
8 | } from '@nestjs/common'; |
||
9 | import {AuthGuard} from '@nestjs/passport'; |
||
10 | import {ApiUseTags, ApiBearerAuth, ApiOperation} from '@nestjs/swagger'; |
||
11 | import {IQueryBus} from 'src/Application/IQueryBus'; |
||
12 | import {EventIdDTO} from './DTO/EventIdDTO'; |
||
13 | import {GetEventByIdQuery} from 'src/Application/FairCalendar/Query/GetEventByIdQuery'; |
||
14 | import {EventView} from 'src/Application/FairCalendar/View/EventView'; |
||
15 | |||
16 | @Controller('events') |
||
17 | @ApiUseTags('Event') |
||
18 | @ApiBearerAuth() |
||
19 | @UseGuards(AuthGuard('bearer')) |
||
20 | export class GetEventAction { |
||
21 | constructor( |
||
22 | @Inject('IQueryBus') |
||
23 | private readonly queryBus: IQueryBus |
||
24 | ) {} |
||
25 | |||
26 | @Get(':id') |
||
27 | @ApiOperation({title: 'Get event'}) |
||
28 | public async index(@Param() dto: EventIdDTO): Promise<EventView> { |
||
29 | try { |
||
30 | return await this.queryBus.execute(new GetEventByIdQuery(dto.id)); |
||
31 | } catch (e) { |
||
32 | throw new BadRequestException(e.message); |
||
33 | } |
||
34 | } |
||
35 | } |
||
36 |