const buildDate = +Date.now(); var middleware = (module.exports = { ensureAuthenticated: function (req, res, next) { if (!req.isAuthenticated()) { req.session.returnTo = req.path; return res.redirect("/login"); } next(); }, ensureLocals: function (req, res, next) { res.locals.csrfToken = req.csrfToken ? req.csrfToken() : "csrf"; res.locals.title = "bucky"; (res.locals.buildDate = buildDate), (res.locals.env = process.env.NODE_ENV); if (req.isAuthenticated()) { res.locals.show_header = true; res.locals.preload = JSON.stringify({ env: res.locals.env, buildDate: buildDate, s3: { bucket: process.env.S3_BUCKET, path: process.env.S3_PATH, }, }); } else { res.locals.show_header = false; res.locals.preload = JSON.stringify({ env: res.locals.env, }); } next(); }, });