Skip to content

Commit

Permalink
refactor(back): expose full download URLs in maplistversion DTO
Browse files Browse the repository at this point in the history
  • Loading branch information
tsa96 committed Feb 20, 2024
1 parent b18775a commit 42b3eb5
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
30 changes: 29 additions & 1 deletion apps/backend/src/app/dto/map/map-list-version.dto.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,41 @@
import { MapListVersion } from '@momentum/constants';
import { FlatMapList, mapListPath, MapListVersion } from '@momentum/constants';
import { ApiProperty } from '@nestjs/swagger';
import { IsInt } from 'class-validator';
import { Expose } from 'class-transformer';
import { Config } from '../../config';

const ENDPOINT_URL = Config.storage.endpointUrl;
const BUCKET = Config.storage.bucketName;

export class MapListVersionDto implements MapListVersion {
@ApiProperty({ description: 'Latest version of the main map list' })
@IsInt()
approved: number;

@ApiProperty({
description: 'URL to the latest version of the main map list in file store'
})
@Expose()
get approvedURL(): string {
return `${ENDPOINT_URL}/${BUCKET}/${mapListPath(
FlatMapList.APPROVED,
this.approved
)}`;
}

@ApiProperty({ description: 'Latest version of the submission map list' })
@IsInt()
submissions: number;

@ApiProperty({
description:
'URL to the latest version of the submission map list in file store'
})
@Expose()
get submissionsURL(): string {
return `${ENDPOINT_URL}/${BUCKET}/${mapListPath(
FlatMapList.SUBMISSION,
this.submissions
)}`;
}
}
2 changes: 2 additions & 0 deletions libs/constants/src/types/models/map/map-list-version.model.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export interface MapListVersion {
approved: number;
approvedURL: string;
submissions: number;
submissionsURL: string;
}

0 comments on commit 42b3eb5

Please sign in to comment.