Passed
Push — master ( 35f7b5...0f9eb0 )
by Mathieu
05:51
created

FileDirectoryStrategy   A

Complexity

Total Complexity 1

Size/Duplication

Total Lines 11
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 11
dl 0
loc 11
c 0
b 0
f 0
rs 10

1 Function

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