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.

28 lines
567 B

6 years ago
  1. module.exports = (req, res, next) => {
  2. if (res.marko) {
  3. res.markoAsync = async(template, input) => {
  4. const locals = Object.assign((res.locals || {}), input)
  5. for (const key in locals) {
  6. const value = locals[key]
  7. if (value instanceof Promise) {
  8. locals[key] = await value
  9. }
  10. }
  11. return res.marko(template, locals)
  12. }
  13. }
  14. if (req.user) {
  15. res.locals.user = {
  16. loggedIn: true,
  17. name: req.user._json.name,
  18. }
  19. } else {
  20. res.locals.user = {
  21. loggedIn: false,
  22. }
  23. }
  24. next()
  25. }