Can you explain more about how the client views and the application views work? That is, when you are a user and you access the application, what happens when you choose a client view? What happens when you choose a server view? How does the application manage the navigation between them, the requests and responses (via req and res), and the session data, etc.? This part is extremely confusing for those new to node and this discussion would be extremely helpful. I think you have the bits and pieces in various places in the book, but having it together would be great as a way to provide the "big picture view" of how this all works.
One thing in particular that I think is very confusing, because Node is the server and the application, when you request a view from public (a client view), the application serves it up based on a path (I presume). What happens when you respond with a 200? Does the browser load a new page showing the 200 response? Or does it leave the user on the client view page?
Why did we not have to specify where the views are for the application like we did in the previous chapters, with:
app.set('views', __dirname + '/views');
Could you explain more about how the module.exports works?
Is module a built-in keyword? It would appear that when you "require" the Account module, what's returned is the function in module.exports, which you then immediately apply to get an object, the one that's returned at the bottom of this function. But it's unclear how we know to use "module.exports"? Is this a node thing? a requirejs thing? an express thing? something else entirely?
In the configure function in app.js, I feel like I've missed quite a few huge things. How do we know we need the bodyParser to parse the forms? Why do we need the cookieParser and how do we know we need that? Is it related to sessions? How do we know how to set up the session? How do we know we need a memory store? What other kinds of stores are there? What are the tradeoffs? How do we know what url to use when connecting to mongodb? Why connect to mongodb here? Does this connection stay alive for the entire application? Is it a separate connection for each user that accesses app.js? How do we know what order to do all this stuff in?
There is so much about Node that is a complete mystery. People just seem to "know" what modules they need, what pieces to install, which pieces work with other pieces, etc. And yet I have not found anywhere an explanation for any of this stuff. It's like each book says to do it just a bit differently without explaining why, or how one learns the nuances of the decisions one needs to make for an application.
And most importantly, at the end of Chapter 6, can I run this application and see my work at this point? If so, how? Which page do I access to get to the "top level"? How do I debug if I have errors? This would be incredibly useful information. As it is, I feel like I've been following along and am left hanging...
Thank you! I know this is a lot of questions, so I appreciate any response and help.