Добавлены конвертеры времени и url
This commit is contained in:
parent
1a65ab7fca
commit
d833c68455
2 changed files with 26 additions and 0 deletions
9
libs/event-emitter/src/utils/timestamp-converter.ts
Normal file
9
libs/event-emitter/src/utils/timestamp-converter.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
/* eslint-disable @typescript-eslint/no-namespace */
|
||||||
|
export namespace TimestampConverter {
|
||||||
|
export function toTimestamp(date: string): number {
|
||||||
|
return new Date(date).getTime();
|
||||||
|
}
|
||||||
|
export function toString(date: number): string {
|
||||||
|
return new Date(date).toISOString();
|
||||||
|
}
|
||||||
|
}
|
||||||
17
src/converters/redmine-public-url.converter.ts
Normal file
17
src/converters/redmine-public-url.converter.ts
Normal file
|
|
@ -0,0 +1,17 @@
|
||||||
|
import { Injectable } from '@nestjs/common';
|
||||||
|
import { ConfigService } from '@nestjs/config';
|
||||||
|
|
||||||
|
@Injectable()
|
||||||
|
export class RedminePublicUrlConverter {
|
||||||
|
private redminePublicUrlPrefix: string;
|
||||||
|
|
||||||
|
constructor(private configService: ConfigService) {
|
||||||
|
this.redminePublicUrlPrefix = this.configService.get<string>(
|
||||||
|
'redmineIssueEventEmitterConfig.redmineUrlPublic',
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
convert(issueId: number | string): string {
|
||||||
|
return `${this.redminePublicUrlPrefix}/issues/${issueId}`;
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue