ddstats-server/libs/routex.js

22 lines
592 B
JavaScript

export default function routex(req, res) {
if (req.baseUrl === "/api")
return function(_, data, success, __) {
if (success)
return res.json({
success,
response: data
})
return res.json({
success,
response: data.error
})
}
return function(template, data, success, options) {
if (success)
return res.render(template, { data, options })
return res.render("pages/error.njk", { data, options })
}
}