obs-portal/routes/api/index.js

24 lines
623 B
JavaScript
Raw Normal View History

2020-11-20 10:02:30 +00:00
const router = require('express').Router();
router.use('/', require('./users'));
router.use('/profiles', require('./profiles'));
router.use('/tracks', require('./tracks'));
router.use('/tags', require('./tags'));
router.use('/accounts', require('../../accounts/accounts.controller'));
router.use(function (err, req, res, next) {
if (err.name === 'ValidationError') {
return res.status(422).json({
errors: Object.keys(err.errors).reduce(function (errors, key) {
errors[key] = err.errors[key].message;
return errors;
2020-11-20 10:02:30 +00:00
}, {}),
});
}
return next(err);
});
2020-08-14 10:37:34 +00:00
module.exports = router;