Tuesday 10 October 2017

Noob here - Require modules once or in multiple files?

Let's say I'm setting up Passport and in my main app.js at the top of the file I have:const passport = require('passport'); If I also have a separate Passport config file being required in my main app.js is it best to pass the passport variable to it like so (I think that's what's happening, right?):require('./config/passport')(passport); or to just require it again at the top of my passport.js file...const passport = require('passport'); Does it make a difference?Can I also do something like this in main app.js:require('./routes/article')(express); As opposed to this in routes/article.js:const express = require('express'); const router = express.Router(); Thanks!

Submitted October 10, 2017 at 02:43PM by throwawaylayman90

No comments:

Post a Comment