From 413722ce68fb866057c6da6efededccc4f76ace0 Mon Sep 17 00:00:00 2001 From: Bobby Wibowo Date: Mon, 2 Nov 2020 18:39:28 +0700 Subject: [PATCH] linted routes/album.js --- routes/album.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/routes/album.js b/routes/album.js index aec8e8f..f1bc8c9 100644 --- a/routes/album.js +++ b/routes/album.js @@ -7,8 +7,9 @@ const db = require('knex')(config.database) routes.get('/a/:identifier', async (req, res, next) => { const identifier = req.params.identifier - if (identifier === undefined) + if (identifier === undefined) { res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404])) + } const album = await db.table('albums') .where({ @@ -18,8 +19,9 @@ routes.get('/a/:identifier', async (req, res, next) => { .select('id', 'name', 'identifier', 'editedAt', 'download', 'public', 'description') .first() - if (!album || album.public === 0) + if (!album || album.public === 0) { return res.status(404).sendFile(path.join(paths.errorRoot, config.errorPages[404])) + } const nojs = req.query.nojs !== undefined @@ -28,21 +30,23 @@ routes.get('/a/:identifier', async (req, res, next) => { // Cache ID - we initialize a separate cache for No-JS version cacheid = nojs ? `${album.id}-nojs` : album.id - if (!utils.albumsCache[cacheid]) + if (!utils.albumsCache[cacheid]) { utils.albumsCache[cacheid] = { cache: null, generating: false } + } - if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) + if (!utils.albumsCache[cacheid].cache && utils.albumsCache[cacheid].generating) { return res.render('album-notice', { config, versions: utils.versionStrings, album, notice: 'This album\'s public page is still being generated. Please try again later.' }) - else if (utils.albumsCache[cacheid].cache) + } else if (utils.albumsCache[cacheid].cache) { return res.send(utils.albumsCache[cacheid].cache) + } utils.albumsCache[cacheid].generating = true }