Use includes on liked, music, score, search and fav pages

This commit is contained in:
2023-11-29 21:45:53 +01:00
parent eff5eae706
commit c0bc611268
9 changed files with 169 additions and 237 deletions
+6 -19
View File
@@ -1,33 +1,20 @@
import * as yup from 'yup';
import ResponseHandler from './ResponseHandler';
import Song from './Song';
import Song, { SongValidator } from './Song';
import Model, { ModelValidator } from './Model';
export const LikedSongValidator = yup
.object({
songId: yup.number().required(),
song: yup.lazy(() => SongValidator.default(undefined)),
addedDate: yup.date().required(),
})
.concat(ModelValidator);
export const LikedSongHandler: ResponseHandler<
yup.InferType<typeof LikedSongValidator>,
LikedSong
> = {
validator: LikedSongValidator,
transformer: (likedSong) => ({
id: likedSong.id,
songId: likedSong.songId,
addedDate: likedSong.addedDate,
}),
};
interface LikedSong extends Model {
songId: number;
addedDate: Date;
}
export type LikedSong = yup.InferType<typeof LikedSongValidator>;
export interface LikedSongWithDetails extends LikedSong {
details: Song;
}
export const LikedSongHandler: ResponseHandler<LikedSong> = {
validator: LikedSongValidator,
};
export default LikedSong;