Saturday, 3 June 2017

How to make module (such as bcrypt) available globally in Express?

I have several "routes" files where I import modules like this:

var bcrypt = require('bcryptjs');

I have attempted to make bcrypt available globally by importing it into my main app js and then using an app.use() something like this:

var bcrypt = require('bcryptjs');
app.use(bcrypt); // clearly not right, app crashes

I've tried a variety of things here. Should I just stick with importing this into every file separately or is there a good way to make this module available globally?



via Alan

No comments:

Post a Comment