node.js - Node require syntax -


i new javascript , newer node. trying read express server code , can't figure out following line in app.js file:

module.require('./auth')(passport); 

i know have variable holds passport module in app.js:

var passport = require('passport'); 

and have auth.js in same directory exports following function:

module.exports = function(passport) {     passport.use('local-login', new localstrategy({         usernamefield: 'email'     }, function(idpemail, password, done) {         // email mapping         findemailfromdummydb(idpemail, password,function(err,user){             if(err) {                 done(null, false, {                     messages: err.tostring()                 });             } else {                 done(null, {                     sysemail: user.sysemail                 });             }         });     })); 

however, following function do?

module.require('./auth')(passport); 

module.require('./auth') imports function, get's called passport parameter. it's same

const auth = require('./auth'); const passport = require('passport'); auth = auth(passport); 

Comments

Popular posts from this blog

c# - Update a combobox from a presenter (MVP) -

How to understand 2 main() functions after using uftrace to profile the C++ program? -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -