-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add ts types, change spotify link to link and account tokens
- Loading branch information
Showing
21 changed files
with
255 additions
and
144 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,11 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsEmail } from 'class-validator' | ||
|
||
export class AddJukeboxLinkDto { | ||
export class AddJukeboxLinkDto implements Partial<IJukeboxLink> { | ||
@ApiProperty() | ||
type: JukeboxLinkType | ||
|
||
@ApiProperty() | ||
@IsEmail() | ||
spotifyEmail: string | ||
email: string | ||
} |
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,41 +1,53 @@ | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { Expose } from 'class-transformer' | ||
import { BaseDto } from 'src/config/dtos' | ||
import { SpotifyLinkDto, SpotifyLinkNestedDto } from 'src/spotify/dto/spotify-link.dto' | ||
import { Jukebox } from '../entities/jukebox.entity' | ||
|
||
export class JukeboxDto extends BaseDto { | ||
export class JukeboxLinkDto implements IJukeboxLink { | ||
@Expose() | ||
@ApiProperty() | ||
id: number | ||
|
||
@Expose() | ||
@ApiProperty() | ||
name: string | ||
type: JukeboxLinkType | ||
|
||
@Expose() | ||
@ApiProperty() | ||
club_id: number | ||
email: string | ||
|
||
@Expose() | ||
@ApiProperty() | ||
active: boolean | ||
} | ||
|
||
export class JukeboxDto extends BaseDto implements IJukebox { | ||
@Expose() | ||
@ApiProperty() | ||
spotify_links: SpotifyLinkNestedDto[] | ||
id: number | ||
|
||
@Expose() | ||
@ApiProperty() | ||
name: string | ||
|
||
@Expose() | ||
@ApiProperty() | ||
club_id: number | ||
|
||
@Expose() | ||
@ApiProperty() | ||
active_spotify_link?: SpotifyLinkDto | ||
links: JukeboxLinkDto[] | ||
|
||
static serialize(entity: Jukebox): JukeboxDto { | ||
return { | ||
...super.serialize(entity), | ||
name: entity.name, | ||
club_id: entity.club_id, | ||
spotify_links: | ||
entity.spotify_link_assignments?.map((assignment) => ({ | ||
spotify_email: assignment.spotify_link.spotify_email, | ||
})) ?? [], | ||
active_spotify_link: entity.spotify_link_assignments?.find((assignment) => assignment.active) | ||
?.spotify_link, | ||
} | ||
} | ||
// static serialize(entity: Jukebox): JukeboxDto { | ||
// return { | ||
// ...super.serialize(entity), | ||
// name: entity.name, | ||
// club_id: entity.club_id, | ||
// links: | ||
// entity.spotify_link_assignments?.map((assignment) => ({ | ||
// type: 'spotify', | ||
// email: assignment.spotify_link.spotify_email, | ||
// active: assignment.active, | ||
// })) ?? [], | ||
// } | ||
// } | ||
} |
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,14 +1,8 @@ | ||
import { ApiProperty, PartialType } from '@nestjs/swagger' | ||
import { SpotifyLinkNestedDto } from 'src/spotify/dto/spotify-link.dto' | ||
import { CreateJukeboxDto } from './create-jukebox.dto' | ||
import { ApiProperty } from '@nestjs/swagger' | ||
import { IsOptional } from 'class-validator' | ||
|
||
export class UpdateJukeboxDto { | ||
export class UpdateJukeboxDto implements Partial<IJukebox> { | ||
@IsOptional() | ||
@ApiProperty() | ||
name?: string | ||
|
||
@IsOptional() | ||
@ApiProperty() | ||
active_spotify_link?: SpotifyLinkNestedDto | ||
} |
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
Oops, something went wrong.