router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.post('/books/edit', async (req, res) => { try { await Book.edit(req.body); res.json({ done: 1 }); } catch (err) { res.json({ error: err.message || err.toString() }); } });
router.use('/', (req, res, next) => { const validation = joi.validate(req.body, authValidation); if (!validation.error) { next(); } else { res.status(422).json({ message: 'Validation error.', error: validation.error, }); } });
app.use((req, res, next) => { if (!req.user) { res.redirect('/auth/google'); return; } next(); });
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });
router.post('/books/edit', async (req, res) => { try { const editedBook = await Book.edit(req.body); res.json(editedBook); } catch (err) { res.json({ error: err.message || err.toString() }); } });
router.use((req, res, next) => { if (!req.user) { res.status(401).json({ error: 'Unauthorized' }); return; } next(); });