1 import * as express from 'express'
2 import { VideoPlaylistModel } from '../../models/video/video-playlist'
3 import { MVideoPlaylist } from '../../types/models/video/video-playlist'
4 import { HttpStatusCode } from '../../../shared/core-utils/miscs/http-error-codes'
6 export type VideoPlaylistFetchType = 'summary' | 'all'
7 async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') {
8 if (fetchType === 'summary') {
9 const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined)
10 res.locals.videoPlaylistSummary = videoPlaylist
12 return handleVideoPlaylist(videoPlaylist, res)
15 const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
16 res.locals.videoPlaylistFull = videoPlaylist
18 return handleVideoPlaylist(videoPlaylist, res)
21 // ---------------------------------------------------------------------------
24 doesVideoPlaylistExist
27 // ---------------------------------------------------------------------------
29 function handleVideoPlaylist (videoPlaylist: MVideoPlaylist, res: express.Response) {
31 res.status(HttpStatusCode.NOT_FOUND_404)
32 .json({ error: 'Video playlist not found' })