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();
|
|
|
|
}
|
|
|
|
},
|
2020-10-29 08:25:05 -07:00
|
|
|
verifyAuth(),
|
2018-11-20 11:19:58 -08:00
|
|
|
(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')());
|
2020-10-30 08:15:00 -07:00
|
|
|
router.use('/resetpw', require('./resetpw')(db));
|
2020-10-29 20:50:36 -07:00
|
|
|
router.use('/confirm-account', require('./confirm-account')(db));
|
2018-11-20 11:19:58 -08:00
|
|
|
|
|
|
|
router.use('/wishlist', require('./wishlist')(db));
|
2020-11-05 14:42:24 -08:00
|
|
|
router.use('/supported-sites', require('./supported-sites')())
|
2018-11-20 11:19:58 -08:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|