Skip to content

Commit cdfca9b

Browse files
committed
fix: return null for lyrics id if not available
1 parent b592dd0 commit cdfca9b

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

src/modules/songs/helpers/song.helper.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ export const createSongPayload = (song: z.infer<typeof SongAPIResponseModel>): z
1515
playCount: Number(song.play_count || 0),
1616
language: song.language,
1717
hasLyrics: song.more_info?.has_lyrics === 'true',
18-
lyricsId: song.more_info?.lyrics_id ?? null,
18+
lyricsId: song.more_info?.lyrics_id || null,
1919
url: song.perma_url,
2020
copyright: song.more_info?.copyright_text,
2121
album: {

src/modules/songs/models/song.model.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const SongModel = z.object({
6969
playCount: z.number(),
7070
language: z.string(),
7171
hasLyrics: z.boolean(),
72-
lyricsId: z.string(),
72+
lyricsId: z.string().nullable(),
7373
lyrics: LyricsModel.optional(),
7474
url: z.string(),
7575
copyright: z.string(),

src/modules/songs/use-cases/get-song-by-id/get-song-by-id.use-case.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ export class GetSongByIdUseCase implements IUseCase<GetSongByIdArgs, z.infer<typ
2626

2727
if (!response.songs?.length) throw new HTTPException(404, { message: 'song not found' })
2828

29-
const songs = response.songs.map((element) => createSongPayload(element))
29+
const songs = response.songs.map((song) => createSongPayload(song))
3030

3131
if (includeLyrics) {
3232
await Promise.all(

0 commit comments

Comments
 (0)