Issue
I am working on an Single Page Application with Web Api and Angular JS. I want to grab all the best practices for a great spa applications.
I want to know that is that a best practice to host Web Api project as a seperate project or just include with in same project along with your spa.
Thanks
Solution
I believe your best bet is to have the SPA into a separate project and even better a different repository, since this is more flexible and supports many different development/deployment scenarios, especially as your project grows bigger.
I personally started with the mixed files approach and moved to the separate Repos approach just days after the project went beyond the size of the Todos examples.
Some of the pros of having separate projects/repos are:
- better search context for search/replace or goto file/class.
- fewer files per project/solution so visual studio is not crawling to its knees.
- you can use different editors, more easily, for your spa project if you get better support for javascript/typescript there than in VS (eg. webstorm).
- file structure is more readable in the small solution explorer window since there is less nesting
- different people can work independently on the frontend/backend
- your SPA can have its own versioning and you can mix and match FE/BE versions as required
- simpler continuous integration since you do not mix frontend/backend build steps
- you can decide at deployment time if they are going to be hosted on
the same host, or different machines (after enabling CORS support) - Finally it makes your SPA a first class citizen and not just a subfolder of your web api.
On the opposite side I cannot think of any advantage of having the SPA as a subfolder to the WebApi except maybe for very small projects that you want to keep complexity to a minimum.
Answered By - masimplo
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.