You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
564 B
22 lines
564 B
const bodeParser = require('body-parser')
|
|
const {success} = require('./util')
|
|
const {apiPrefix, useMock} = require('../src/config')
|
|
|
|
const routes = require('./controller')
|
|
|
|
module.exports = app => {
|
|
if (!useMock) return
|
|
|
|
app.use(bodeParser.json())
|
|
|
|
routes.forEach(route => {
|
|
app[route.method](
|
|
apiPrefix + route.url,
|
|
(req, res) => {
|
|
if (typeof route.res === 'function') {
|
|
route.res(req, res)
|
|
}
|
|
else res.send(success(route.res))
|
|
})
|
|
})
|
|
}
|
|
|