Passed
Pull Request — master (#143)
by Mathieu
04:31 queued 02:15
created

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

Complexity

Total Complexity 1
Complexity/F 1

Size

Lines of Code 16
Function Count 1

Duplication

Duplicated Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
wmc 1
eloc 13
mnd 0
bc 0
fnc 1
dl 0
loc 16
bpm 0
cpm 1
noi 0
c 0
b 0
f 0
rs 10
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