I am running app.js on node server. Since the site requires login, i want to host just 1 app.get('/') on app.js.
Upon successful log-in by user, i want to swap the file app.js to app2.js which will now include more app2.get('/home'), app2.get('/otherfeature') etc.
(Assuming you're using Express) You can create some middleware that checks if the user is authenticated. If they are, it forwards the request; otherwise, it does whatever it needs. See app.use in the documentation for more information.
It turns out that if you want to apply middleware to specific routes, you can; just pass the middleware as additional arguments after the path and before the main handler.