Just wondering how can I have an object which is accessible everywhere models, controllers etc in SailsJS. I need this mostly for some utility functions which I use quite often. Do you think that's a good idea?
EDIT: What's the remended way to do this
Just wondering how can I have an object which is accessible everywhere models, controllers etc in SailsJS. I need this mostly for some utility functions which I use quite often. Do you think that's a good idea?
EDIT: What's the remended way to do this
Share edited Jan 25, 2014 at 13:02 Petar Vasilev asked Jan 24, 2014 at 21:54 Petar VasilevPetar Vasilev 4,7556 gold badges47 silver badges78 bronze badges 2- then make a global utils object or use require or hide it as a property of another global. – dandavis Commented Jan 24, 2014 at 22:20
- whats the remended way to do this, is it just go into bootstrap.js and do: global.utils = require('lib/utils'); ? – Petar Vasilev Commented Jan 24, 2014 at 22:35
1 Answer
Reset to default 8See the documentation for Services in the Sails docs. They sound like exactly what you're looking for--custom modules that are globalized for use throughout your app.