Currently my test app is configured this way.
WebAPI is responsible for
- taking requests from client app
- communicating with MongoDB
- sending back responses.
And it use Node.js as web server and express 4 as back-end routing framework.
ClientApp is a front-end app based on Angular2 and uses another Node.js instance to serve as web server without Express 4. It does not use Express because there is no need. All the client-side routing is done by Angular2.
So I have two "backends" Node.js servers, one for WebAPI and the other for ClientApp.
The above works fine. My questions are that
Is it common to combined the two apps (the WebAPI and ClientApp) under one Node.js server?
If yes, would the Express routing URI and Angular2 router URI get confused with each other?
If yes what are the advantages and disadvantages?
If yes, then what are the common folder structure look like?
proj-root
|--routes folder (for express) |--views folder (for express, actually there is no view for WebAPI) |--models folder (for WebAPI with mongoose) |--services folder (for WebAPI) |--app folder (for Anglar2 components) |-- views folder (for Angular2 html views) |--node_modules folder (for both) |--index.html (Angular2 start point) |--server.js (Express 4 startup file) |--package.json (for both) |--blabla
Does the above look OK?