Skip to content

Commit

Permalink
organize base schemas for types
Browse files Browse the repository at this point in the history
  • Loading branch information
IkeHunter committed Jan 14, 2025
1 parent d574427 commit 6f11b8b
Show file tree
Hide file tree
Showing 7 changed files with 23 additions and 15 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -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

Expand Down
8 changes: 8 additions & 0 deletions src/config/entities.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
7 changes: 2 additions & 5 deletions src/jukebox/dto/jukebox-link.dto.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
6 changes: 2 additions & 4 deletions src/jukebox/entities/jukebox.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
}
}
Expand All @@ -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,
Expand Down
5 changes: 5 additions & 0 deletions src/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
declare interface IModel {
id: number
created_at: Date
updated_at: Date
}
6 changes: 2 additions & 4 deletions src/types/jukebox.d.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
declare interface IJukebox {
id: number
declare interface IJukebox extends IModel {
name: string
club_id: number
links: IJukeboxLink[]
}

declare type JukeboxLinkType = 'spotify'

declare interface IJukeboxLink {
id: number
declare interface IJukeboxLink extends IModel {
type: JukeboxLinkType
email: string
active: boolean
Expand Down
3 changes: 1 addition & 2 deletions src/types/spotify-auth.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
declare interface ISpotifyAccount {
id: number
declare interface ISpotifyAccount extends IModel {
access_token: string
user_id: number
spotify_email: string
Expand Down

0 comments on commit 6f11b8b

Please sign in to comment.