Last active
August 29, 2015 14:03
-
-
Save prestonp/c494723bdc79f94072c2 to your computer and use it in GitHub Desktop.
dirac plugins
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// monkey patches dirac with ./plugins folder | |
var dirac = require('dirac'); | |
modules.exports = function(options) { | |
options = options || {}; | |
// plugins folder contains table folders, each containing plugin definitions | |
fs.readDir(options.path || './plugins'); | |
// pseudocode | |
foreach table | |
foreach plugin | |
dirac.dals[table][plugin.type](plugin.method, plugin.handler); | |
}; | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ./plugins/orders/statuses.js | |
module.exports = [ | |
{ type: 'before' | |
, method: 'find' | |
, handler: function submittedDate( $query, schema, next) { } | |
}, | |
{ type: 'before' | |
, method: 'findOne' | |
, handler: function statusDateSort( $query, schema, next) { } | |
} | |
]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment