Skip to content

Commit

Permalink
refactor: changed way middleware was exported
Browse files Browse the repository at this point in the history
  • Loading branch information
julianlam committed Aug 21, 2020
1 parent f00595b commit cf2f1e9
Show file tree
Hide file tree
Showing 3 changed files with 196 additions and 192 deletions.
10 changes: 6 additions & 4 deletions src/middleware/admin.js
Expand Up @@ -18,13 +18,15 @@ var controllers = {
helpers: require('../controllers/helpers'),
};

module.exports.buildHeader = helpers.try(async function (req, res, next) {
const middleware = module.exports;

middleware.buildHeader = helpers.try(async function (req, res, next) {
res.locals.renderAdminHeader = true;
res.locals.config = await controllers.api.loadConfig(req);
next();
});

module.exports.renderHeader = async (req, res, data) => {
middleware.renderHeader = async (req, res, data) => {
var custom_header = {
plugins: [],
authentication: [],
Expand Down Expand Up @@ -96,11 +98,11 @@ async function getLatestVersion() {
return null;
}

module.exports.renderFooter = async function (req, res, data) {
middleware.renderFooter = async function (req, res, data) {
return await req.app.renderAsync('admin/footer', data);
};

module.exports.checkPrivileges = async (req, res, next) => {
middleware.checkPrivileges = async (req, res, next) => {
// Kick out guests, obviously
if (!req.uid) {
return controllers.helpers.notAllowed(req, res);
Expand Down

0 comments on commit cf2f1e9

Please sign in to comment.