diff --git a/Makefile b/Makefile index 957e01e..03d07ac 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,6 @@ +network: + docker-compose -f docker-compose.network.yml up + network-server: ./Dockerfile docker-compose -f docker-compose.network.yml up server diff --git a/src/config/entities.ts b/src/config/entities.ts index 05010ce..ce42364 100644 --- a/src/config/entities.ts +++ b/src/config/entities.ts @@ -22,4 +22,12 @@ export class BaseEntity extends TypeormBase { @DeleteDateColumn({ nullable: true }) deleted_on: Date + + serialize() { + return { + id: this.id, + created_at: this.created_at, + updated_at: this.updated_at, + } + } } diff --git a/src/jukebox/dto/jukebox-link.dto.ts b/src/jukebox/dto/jukebox-link.dto.ts index 3aba711..6ae0251 100644 --- a/src/jukebox/dto/jukebox-link.dto.ts +++ b/src/jukebox/dto/jukebox-link.dto.ts @@ -1,11 +1,8 @@ import { ApiProperty } from '@nestjs/swagger' import { Expose } from 'class-transformer' +import { BaseDto } from 'src/config/dtos' -export class JukeboxLinkDto implements IJukeboxLink { - @Expose() - @ApiProperty() - id: number - +export class JukeboxLinkDto extends BaseDto implements IJukeboxLink { @Expose() @ApiProperty() type: JukeboxLinkType diff --git a/src/jukebox/entities/jukebox.entity.ts b/src/jukebox/entities/jukebox.entity.ts index 2ecee6d..a59884a 100644 --- a/src/jukebox/entities/jukebox.entity.ts +++ b/src/jukebox/entities/jukebox.entity.ts @@ -28,12 +28,10 @@ export class Jukebox extends BaseEntity { serialize(): JukeboxDto { return { - id: this.id, + ...super.serialize(), name: this.name, club_id: this.club_id, links: this.link_assignments?.map((assignment) => assignment.serialize()) ?? [], - created_at: this.created_at, - updated_at: this.updated_at, } } } @@ -59,7 +57,7 @@ export class JukeboxLinkAssignment extends BaseEntity { serialize(): JukeboxLinkDto { return { - id: this.id, + ...super.serialize(), type: 'spotify', email: this.spotify_link.spotify_email, active: this.active, diff --git a/src/types/index.d.ts b/src/types/index.d.ts new file mode 100644 index 0000000..7de6f40 --- /dev/null +++ b/src/types/index.d.ts @@ -0,0 +1,5 @@ +declare interface IModel { + id: number + created_at: Date + updated_at: Date +} diff --git a/src/types/jukebox.d.ts b/src/types/jukebox.d.ts index b7a4ef1..0d1a92b 100644 --- a/src/types/jukebox.d.ts +++ b/src/types/jukebox.d.ts @@ -1,5 +1,4 @@ -declare interface IJukebox { - id: number +declare interface IJukebox extends IModel { name: string club_id: number links: IJukeboxLink[] @@ -7,8 +6,7 @@ declare interface IJukebox { declare type JukeboxLinkType = 'spotify' -declare interface IJukeboxLink { - id: number +declare interface IJukeboxLink extends IModel { type: JukeboxLinkType email: string active: boolean diff --git a/src/types/spotify-auth.d.ts b/src/types/spotify-auth.d.ts index 7aab3ff..49d2e77 100644 --- a/src/types/spotify-auth.d.ts +++ b/src/types/spotify-auth.d.ts @@ -1,5 +1,4 @@ -declare interface ISpotifyAccount { - id: number +declare interface ISpotifyAccount extends IModel { access_token: string user_id: number spotify_email: string