Since Node.js modules are cached once they are loaded for the first time, reusing require('bcrypt')
or not won't make any difference in terms of performance.
That said, if you are still up for doing it your way, you can require bcrypt
in config/bootstrap.js
and add it to the sails
namespace:
module.exports.bootstrap = function (cb) {
sails.bcrypt = require('bcrypt');
//...
cb();
}
After that you'll be able to use sails.bcrypt
in your controllers or models.