I am building a single page web application with Express.js on the back-end. However, I want to keep the login/register/homepage to the application (before you login) separate from the single page application (after you login), but on the same root URL (/).
My question is how would you recommend designing this? Currently I have server-side templates rendered and served by routes in Express.js for /, /login, and /register (because I don't want the pre-app part of the web site to be appy). Then, when the user logs in, I serve a different server-side template to the / GET route:
app.get('/', function (req, res) {
if (!req.isAuthenticated()) {
return res.render('index');
}
res.render('app')
})
This file then serves the rest of the application by providing a link to the client-side JavaScript (Backbone.js/AngularJS, etc.)
I am looking to receive criticism on this design. Is this the best way for me to achieve my desired application design, using Express.js and a mix of client/server-side templates?