1 import * as express from 'express'
2 import { VideoPlaylistModel } from '../../models/video/video-playlist'
3 import { MVideoPlaylist } from '../../typings/models/video/video-playlist'
5 export type VideoPlaylistFetchType = 'summary' | 'all'
6 async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: VideoPlaylistFetchType = 'summary') {
7 if (fetchType === 'summary') {
8 const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined)
9 res.locals.videoPlaylistSummary = videoPlaylist
11 return handleVideoPlaylist(videoPlaylist, res)
14 const videoPlaylist = await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
15 res.locals.videoPlaylistFull = videoPlaylist
17 return handleVideoPlaylist(videoPlaylist, res)
20 // ---------------------------------------------------------------------------
23 doesVideoPlaylistExist
26 // ---------------------------------------------------------------------------
28 function handleVideoPlaylist (videoPlaylist: MVideoPlaylist, res: express.Response) {
31 .json({ error: 'Video playlist not found' })