| Total Complexity | 1 |
| Complexity/F | 1 |
| Lines of Code | 32 |
| Function Count | 1 |
| Duplicated Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
| 1 | import { Controller, Inject, UseGuards, Post, Param } from '@nestjs/common'; |
||
| 2 | import { AuthGuard } from '@nestjs/passport'; |
||
| 3 | import { ApiTags, ApiBearerAuth, ApiOperation } from '@nestjs/swagger'; |
||
| 4 | import { IQueryBus } from 'src/Application/IQueryBus'; |
||
| 5 | import { IdDTO } from 'src/Infrastructure/Common/DTO/IdDTO'; |
||
| 6 | import { Roles } from 'src/Infrastructure/User/Decorator/Roles'; |
||
| 7 | import { RolesGuard } from 'src/Infrastructure/User/Security/RolesGuard'; |
||
| 8 | import { SchoolUploadEndpointView } from 'src/Application/School/View/SchoolUploadEndpointView'; |
||
| 9 | import { IFileUpload } from 'src/Application/IFileUpload'; |
||
| 10 | |||
| 11 | @Controller('schools') |
||
| 12 | @ApiTags('School') |
||
| 13 | @ApiBearerAuth() |
||
| 14 | @UseGuards(AuthGuard('bearer'), RolesGuard) |
||
| 15 | export class CreateFileIngestionAction { |
||
| 16 | constructor( |
||
| 17 | @Inject('IQueryBus') |
||
| 18 | private readonly queryBus: IQueryBus, |
||
| 19 | @Inject('IFileUpload') |
||
| 20 | private readonly fileUploadAdapter: IFileUpload |
||
| 21 | ) {} |
||
| 22 | |||
| 23 | @Post(':id/photos/ingestion') |
||
| 24 | @Roles('photographer') |
||
| 25 | @ApiOperation({summary: 'Get enpoint to upload files containing photos'}) |
||
| 26 | public async index(@Param() dto: IdDTO): Promise<SchoolUploadEndpointView> { |
||
| 27 | const url = await this.fileUploadAdapter.getEndPoint(`${dto.id}.zip`); |
||
| 28 | |||
| 29 | return new SchoolUploadEndpointView(url); |
||
| 30 | } |
||
| 31 | } |
||
| 32 |