2
votes

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 recommended way to do this

1
then make a global utils object or use require or hide it as a property of another global. - dandavis
whats the recommended way to do this, is it just go into bootstrap.js and do: global.utils = require('lib/utils'); ? - Petar Vasilev

1 Answers

8
votes

See 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.