jeudi 5 janvier 2017

NODE JS APP: What does this notation mean?

I've picked up a project from another developer, uses the typical MEAN stack with the entry point being server.js

Now, in server.js, the module that does:

var express = require('express');

var app = express();

var passport = require('passport');

There are another 2 lines of code that look like they are doing some sort of routing but I can't figure out what it actually means:

require('./routes.js')(app, passport);

require('./apiRequest/authenticate')(app, passport);

I'm confused because it looks like 'require()' is called from the global scope, whereas all the other routing methods are called off app, i.e 'app.use()'. Can someone explain what the sets of parameters mean, and why are there two sets also where is require() called from, is it provided by express?

Aucun commentaire:

Enregistrer un commentaire