Skip to content

Instantly share code, notes, and snippets.

@Kikobeats
Last active August 29, 2015 14:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Kikobeats/8b27a23e4327afdb053f to your computer and use it in GitHub Desktop.
Save Kikobeats/8b27a23e4327afdb053f to your computer and use it in GitHub Desktop.
inject responses sails
/**
* Module dependencies
*/
'use strict';
var buildDictionary = require('sails-build-dictionary');
module.exports = function Responses(sails) {
return {
loadResponses: function(cb) {
async.parallel({
main: function(callback) {
buildDictionary.optional({
dirname : sails.config.paths.responses,
filter : /(.+)\.(js|coffee|litcoffee)$/,
useGlobalIdForKeyName : true
}, callback);
},
modules: function(callback) {
buildDictionary.optional({
dirname : __dirname + '/responses',
filter : /(.+)\.(js|coffee|litcoffee)$/,
useGlobalIdForKeyName : true
}, callback);
}
}, function(err, responses) {
if (err) return cb(err);
return cb(null, sails.util.merge(
// In order for low to high priority
responses.modules,
responses.main
));
});
},
initialize: function(cb)  {
this.loadResponses(cb);
}
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment