Passed
Pull Request — master (#56)
by
unknown
01:56
created

api/src/Infrastructure/School/Action/Photo/CreateFileIngestionAction.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 32
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 29
mnd 0
bc 0
fnc 1
dl 0
loc 32
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10

1 Function

Rating   Name   Duplication   Size   Complexity  
A CreateFileIngestionAction.index 0 8 1
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