From 5430c9f39766bcc00e6f3da5eead25573049e2fd Mon Sep 17 00:00:00 2001 From: unknown <89595418+unknownsrc@users.noreply.github.com> Date: Fri, 24 Mar 2023 16:49:25 +0100 Subject: [PATCH] api error in case piped req fails --- controller/video.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/controller/video.js b/controller/video.js index b2197d2..599bec1 100644 --- a/controller/video.js +++ b/controller/video.js @@ -35,6 +35,8 @@ exports.getVideo = async (req, res) => { exports.getChannel = async (req, res) => { const videos = await metadata.getChannelVideos(req.params.id) const channel = await metadata.getChannel(req.params.id) + + if (!videos || !channel) return res.json({ error: '500' }) if (videos.error) return res.json({ error: '404' }) const archived = await prisma.videos.findMany({ @@ -86,6 +88,8 @@ exports.getChannel = async (req, res) => { exports.getPlaylist = async (req, res) => { const playlist = await metadata.getPlaylistVideos(req.params.id) + + if (!playlist) return res.json({ error: '500' }) if (playlist.error) return res.json({ error: '404' }) const playlistArchived = await prisma.videos.findMany({