Created
April 11, 2014 13:03
-
-
Save davidschreiber/10467093 to your computer and use it in GitHub Desktop.
Sails service with access to config and models
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
var Orbiter = require('../../lib/orbiter').Orbiter; | |
module.exports = function (sails) { | |
return { | |
initialize: function (cb) { | |
// Create a new instance of the service. | |
sails.services.Orbiter = new Orbiter(sails.config.orbiter); | |
// Globally expose service. | |
global.Orbiter = sails.services.Orbiter; | |
// Initialize the object once the waterline models are exposed. | |
sails.after('hook:orm:loaded', function () { | |
sails.services.Orbiter.initialize(cb); | |
}); | |
} | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment