The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

sumeet6689 (1) [Avatar] Offline
In my current project I have the code as below.


exports.home = function(req, res, next) {
console.log("Inside User home");

res.render('user/home', {
angularBootModule: 'user',
user : req.user,
message: req.flash('error')

exports.settings = function(req, res) {
console.log("Inside UserPage Settings");
throw new Error("Not Authorized");

res.render('user/settings', {
user: req.user ? req.user : 'null',
angularBootModule: 'user.settings',


var userPage = require(curDir + '/user/UserHome');
app.get('/user/home', auth.requiresLogin, userPage.home);


The code is working. But my doubt is,

1) What will the require(.. UserHome) do ?
2) What is the value stored in the variable userPage?
3) What does exports.<someFunction> mean ? Suppose if I define a function like
var fun1=function() {
console.log("Inside my function");

Will I be able to access this function like userPage.fun1 ??