christmas/routes/index.js

41 lines
1,005 B
JavaScript
Raw Normal View History

2018-11-20 11:19:58 -08:00
const verifyAuth = require('../middlewares/verifyAuth');
const express = require('express');
const path = require('path');
2019-11-17 12:46:08 -08:00
module.exports = ({ db, config }) => {
2018-11-20 11:19:58 -08:00
const router = express.Router();
router.use('/', express.static(path.join(__dirname, '../static')));
router.get('/',
async (req, res, next) => {
dbInfo = await db.info();
if (dbInfo.doc_count === 0) {
res.redirect('/setup');
} else {
next();
}
},
verifyAuth(),
(req, res) => {
res.redirect('/wishlist');
}
);
2019-11-17 15:05:45 -08:00
router.use('/api', require('./api')({ db }))
2018-11-20 11:19:58 -08:00
router.use('/setup', require('./setup')(db));
router.use('/login', require('./login')());
router.use('/logout', require('./logout')());
router.use('/wishlist', require('./wishlist')(db));
router.use('/profile', require('./profile')(db));
router.use('/admin-settings', require('./adminSettings')(db));
2019-11-17 12:46:08 -08:00
router.use('/manifest.json', require('./manifest.json')({ config }))
2018-11-20 11:19:58 -08:00
return router;
}