2021-11-04 21:33:42 +01:00
|
|
|
export default function routex(req, res) {
|
|
|
|
if (req.baseUrl === "/api")
|
2021-11-05 11:57:17 +01:00
|
|
|
return function(_, data, success, __) {
|
|
|
|
if (success)
|
|
|
|
return res.json({
|
|
|
|
success,
|
|
|
|
response: data
|
|
|
|
})
|
|
|
|
|
|
|
|
return res.json({
|
|
|
|
success,
|
|
|
|
response: data.error
|
|
|
|
})
|
2021-11-04 21:33:42 +01:00
|
|
|
}
|
|
|
|
|
2021-11-05 11:57:17 +01:00
|
|
|
return function(template, data, success, options) {
|
|
|
|
if (success)
|
|
|
|
return res.render(template, { data, options })
|
|
|
|
|
|
|
|
return res.render("pages/error.njk", { data, options })
|
2021-11-04 21:33:42 +01:00
|
|
|
}
|
|
|
|
}
|