Last active
August 29, 2015 14:15
-
-
Save Kikobeats/8b27a23e4327afdb053f to your computer and use it in GitHub Desktop.
inject responses sails
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
/** | |
* 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