epilogue-js
Version:
Create REST resources and controllers with Sequelize and Express or Restify
41 lines (35 loc) • 1.48 kB
JavaScript
var TestMiddlewareBeforeAfter = {
results: {},
extraConfiguration: function(resource) {
TestMiddlewareBeforeAfter.results.extraConfiguration = true;
}
};
TestMiddlewareBeforeAfter.results.extraConfiguration = false;
var actions = ['create', 'list', 'read', 'update', 'delete', 'all'],
milestones = ['start', 'auth', 'fetch', 'data', 'write', 'send', 'complete'];
actions.forEach(function(action) {
TestMiddlewareBeforeAfter.results[action] = {};
TestMiddlewareBeforeAfter[action] = {};
milestones.forEach(function(milestone) {
TestMiddlewareBeforeAfter.results[action][milestone] = {};
TestMiddlewareBeforeAfter.results[action][milestone].action = false;
TestMiddlewareBeforeAfter.results[action][milestone].before = false;
TestMiddlewareBeforeAfter.results[action][milestone].after = false;
TestMiddlewareBeforeAfter[action][milestone] = {
before: function(req, res, context) {
TestMiddlewareBeforeAfter.results[action][milestone].before = true;
return context.continue;
},
action: function(req, res, context) {
TestMiddlewareBeforeAfter.results[action][milestone].action = true;
return context.continue;
},
after: function(req, res, context) {
TestMiddlewareBeforeAfter.results[action][milestone].after = true;
return context.continue;
}
};
});
});
module.exports = TestMiddlewareBeforeAfter;
;