Skip to content

Commit

Permalink
fix: make song fields nullable
Browse files Browse the repository at this point in the history
  • Loading branch information
sumitkolhe committed Mar 30, 2024
1 parent 4787ce9 commit 3467ba3
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 17 deletions.
16 changes: 8 additions & 8 deletions src/modules/songs/helpers/song.helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ export const createSongPayload = (song: z.infer<typeof SongAPIResponseModel>): z
id: song.id,
name: song.title,
type: song.type,
year: Number(song.year || 0),
releaseDate: song.more_info?.release_date,
duration: Number(song.more_info?.duration),
label: song.more_info?.label,
year: song?.year || null,
releaseDate: song.more_info?.release_date || null,
duration: song.more_info?.duration ? Number(song.more_info?.duration) : null,
label: song.more_info?.label || null,
explicitContent: song.explicit_content === '1',
playCount: Number(song.play_count || 0),
language: song.language,
hasLyrics: song.more_info?.has_lyrics === 'true',
lyricsId: song.more_info?.lyrics_id || null,
url: song.perma_url,
copyright: song.more_info?.copyright_text,
copyright: song.more_info?.copyright_text || null,
album: {
id: song.more_info?.album_id,
name: song.more_info?.album,
url: song.more_info?.album_url
id: song.more_info?.album_id || null,
name: song.more_info?.album || null,
url: song.more_info?.album_url || null
},
artists: {
primary: song.more_info?.artistMap?.primary_artists?.map(createArtistMapPayload),
Expand Down
18 changes: 9 additions & 9 deletions src/modules/songs/models/song.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export const SongAPIResponseModel = z.object({
perma_url: z.string(),
image: z.string(),
language: z.string(),
year: z.number(),
year: z.string(),
play_count: z.string(),
explicit_content: z.string(),
list_count: z.string(),
Expand Down Expand Up @@ -61,22 +61,22 @@ export const SongModel = z.object({
id: z.string(),
name: z.string(),
type: z.string(),
year: z.number(),
releaseDate: z.string(),
duration: z.number(),
label: z.string(),
year: z.string().nullable(),
releaseDate: z.string().nullable(),
duration: z.number().nullable(),
label: z.string().nullable(),
explicitContent: z.boolean(),
playCount: z.number(),
language: z.string(),
hasLyrics: z.boolean(),
lyricsId: z.string().nullable(),
lyrics: LyricsModel.optional(),
url: z.string(),
copyright: z.string(),
copyright: z.string().nullable(),
album: z.object({
id: z.string(),
name: z.string(),
url: z.string()
id: z.string().nullable(),
name: z.string().nullable(),
url: z.string().nullable()
}),
artists: z.object({
primary: z.array(ArtistMapModel),
Expand Down

0 comments on commit 3467ba3

Please sign in to comment.