-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: handle pagination + add from/to parameters
- Loading branch information
Showing
11 changed files
with
202 additions
and
137 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,11 @@ | ||
import { Module } from '@nestjs/common'; | ||
import { ExportActivitiesCommandRunner } from './command-runner/export-activities.command-runner'; | ||
import { DownloadFileCommand } from './service/download-file.command'; | ||
import { DownloadFile } from './core/download-file.service'; | ||
import { CorosModule } from './coros/coros.module'; | ||
import { HttpModule } from '@nestjs/axios'; | ||
|
||
@Module({ | ||
imports: [CorosModule, HttpModule], | ||
providers: [ExportActivitiesCommandRunner, DownloadFileCommand], | ||
providers: [ExportActivitiesCommandRunner, DownloadFile], | ||
}) | ||
export class AppModule {} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
export class InvalidParameterError extends Error { | ||
constructor(parameterName: string, reason?: string) { | ||
super(`Invalid parameter ${parameterName}${reason ? `: ${reason}` : ''}`); | ||
this.name = 'InvalidParameterError'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,34 @@ | ||
export enum FileType { | ||
fit = '4', | ||
tcx = '3', | ||
gpx = '1', | ||
kml = '2', | ||
csv = '0', | ||
enum FileType { | ||
fit, | ||
tcx, | ||
gpx, | ||
kml, | ||
csv, | ||
} | ||
export type FileTypeKey = keyof typeof FileType; | ||
|
||
export class FileTypes { | ||
private static readonly All: Record<FileType, { key: string; value: string }> = { | ||
[FileType.fit]: { key: 'fit', value: '4' }, | ||
[FileType.tcx]: { key: 'tcx', value: '3' }, | ||
[FileType.gpx]: { key: 'gpx', value: '1' }, | ||
[FileType.kml]: { key: 'kml', value: '2' }, | ||
[FileType.csv]: { key: 'csv', value: '0' }, | ||
}; | ||
|
||
static get keys() { | ||
return Object.values(FileTypes.All).map(({ key }) => key); | ||
} | ||
|
||
static get default() { | ||
return FileTypes.All[FileType.fit]; | ||
} | ||
|
||
static parse(value: FileTypeKey) { | ||
return FileTypes.All[FileType[value]]; | ||
} | ||
|
||
static isValid(value: string): value is FileTypeKey { | ||
return Object.keys(FileType).some((it) => it === value); | ||
} | ||
} | ||
export type ReadableFileType = keyof typeof FileType; | ||
export const READABLE_FILE_TYPE = Object.keys(FileType); | ||
export const DEFAULT_FILE_TYPE = 'fit'; | ||
export const parseReadableFileType = (value: ReadableFileType): FileType => FileType[value]; |
Oops, something went wrong.