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() }