Passed
Pull Request — master (#87)
by Mathieu
01:33
created

server/src/Domain/File/Strategy/FileLocationStrategy.ts   A

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 14
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

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

1 Function

Rating   Name   Duplication   Size   Complexity  
A FileLocationStrategy.location 0 7 1
1
import {ConfigService} from '@nestjs/config';
2
3
export class FileLocationStrategy {
4
  constructor(private readonly configService: ConfigService) {}
5
6
  public async location(fileName: string, uploadedDate: Date): Promise<string> {
7
    const destination = await this.configService.get<string>('UPLOAD_LOCATION');
8
    const month = uploadedDate.getMonth() + 1;
9
    const year = uploadedDate.getFullYear();
10
11
    return `${destination}/${year}/${month}/${fileName}`;
12
  }
13
}
14