You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
32 lines
670 B
JavaScript
32 lines
670 B
JavaScript
const router = require('express-promise-router')()
|
|
const pg = require('../db/pg')
|
|
|
|
router.use((req, res, next)=>{
|
|
// Skip pretty-printing if in prod
|
|
if(req.app.locals.dev)
|
|
res.json = (val) => {
|
|
res.set('Content-Type', 'application/json');
|
|
res.end(JSON.stringify(val, null, 2))
|
|
}
|
|
|
|
next()
|
|
})
|
|
|
|
router.use('/users/', require('./users'))
|
|
router.use('/items/', require('./items'))
|
|
router.use('/images/', require('./images'))
|
|
router.use('/categories/', require('./categories'))
|
|
|
|
router.get('/', (req, res)=>{
|
|
res.json({test: true})
|
|
})
|
|
|
|
router.use((req, res)=>{
|
|
res.status(404)
|
|
res.json({
|
|
error: 'Not found'
|
|
})
|
|
})
|
|
|
|
module.exports = router;
|