diff --git a/index.js b/index.js index eb7f657..b3ff336 100644 --- a/index.js +++ b/index.js @@ -42,19 +42,24 @@ app.get('/videos', (req, res) => { const list = []; for (const dir of videoDirs) { - if (!fs.existsSync(dir)) { - continue; - } - fs.readdirSync(dir, { recursive: true }).forEach(fileName => { - if (!fileEndings.includes(path.extname(fileName))) { - return; + try { + if (!fs.existsSync(dir)) { + continue; } - const file = { - name: fileName, - path: path.resolve(dir, fileName) - }; - list.push(file); - }); + fs.readdirSync(dir, { recursive: true }).forEach(fileName => { + if (!fileEndings.includes(path.extname(fileName))) { + return; + } + const file = { + name: fileName, + path: path.resolve(dir, fileName) + }; + list.push(file); + }); + } + catch (error) { + console.error(error); + } } res.json(list);