]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - server/helpers/middlewares/video-playlists.ts
Bumped to version v1.4.0
[github/Chocobozzz/PeerTube.git] / server / helpers / middlewares / video-playlists.ts
1 import * as express from 'express'
2 import { VideoPlaylistModel } from '../../models/video/video-playlist'
3
4 async function doesVideoPlaylistExist (id: number | string, res: express.Response, fetchType: 'summary' | 'all' = 'summary') {
5 const videoPlaylist = fetchType === 'summary'
6 ? await VideoPlaylistModel.loadWithAccountAndChannelSummary(id, undefined)
7 : await VideoPlaylistModel.loadWithAccountAndChannel(id, undefined)
8
9 if (!videoPlaylist) {
10 res.status(404)
11 .json({ error: 'Video playlist not found' })
12 .end()
13
14 return false
15 }
16
17 res.locals.videoPlaylist = videoPlaylist
18 return true
19 }
20
21 // ---------------------------------------------------------------------------
22
23 export {
24 doesVideoPlaylistExist
25 }