The frontend/UI server, written in JS using the MarkoJS library
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.
 
 
 
 

37 lines
751 B

module.exports = (req, res, next) => {
if (res.marko) {
res.markoAsync = async(template, input) => {
const locals = Object.assign((res.locals || {}), input)
try {
for (const key in locals) {
const value = locals[key]
if (value instanceof Promise) {
locals[key] = await value
}
}
} catch(err) {
if (JSON.stringify(err) === "{}") {
return next(err)
}
return res.status(404).json(err)
}
return res.marko(template, locals)
}
}
if (req.user) {
res.locals.user = {
loggedIn: true,
name: req.user._json.name,
}
} else {
res.locals.user = {
loggedIn: false,
}
}
next()
}