I am new to Node and I have a total of three JS files:
-
Index.js contains following code:
var router = express.Router(); /* GET home page. */ router.get('/', function(req, res, next) { console.log(arguments); if(req.isAuthenticated()){ res.render('index', { title: 'sp1 - My Application', user: req.user }); }else{ console.log('not authentcated sending to authenticate'); res.redirect('/login'); } });
-
SSO.js contains following code :
var router = express.Router(); router.get('/spinitsso-redirect', function (req, res) { console.log('got a redirection from idp'); sp.sendLoginRequest(idp, 'redirect', function (url) { res.redirect(url); }); });
-
App.js contains following code:
var app = express(); var server = app.listen(4002, function () { var host = server.address().address; var port = server.address().port; console.log('Example app listening at http://%s:%s', host, port); });
Question:
How are two different files (index.js and sso.js) are able to add middleware to the same router instance? Is this some of static property of Express where you can add router/middlerware from any JS file in your code?
via nitinsh99
No comments:
Post a Comment