Pergunta

I am a java developer. Since one of our developers are leaving I was handed over a project he was maintaining. He says it is a node + angular js project. But as per my understanding, backend should be written in node js (just as we do java api development) and front end should be written in angular as a separate application. These two applications should be hosted separately and the angular front end should call node js backend for any requests required. So I am confused what is meant by angular+node in the same application and they are hosted as a single application. Can someone experienced in this area please enlighten me?

Foi útil?

Solução

Its fairly normal to have your webpages and js served by the same webapplication which also hosts your api code.

This simple approach has some upsides. You dont have to do anything special with cross site scripting controls, code and ui are in the same place etc.

And also some downsides. you can't deploy new versions of the api separately to the UI and vice versa.

Given that the UI is often tightly coupled to the api responses I would suggest going for a dual api aproach. Have a seperate api project, but also have a server side component of your UI.

So angular calls its local api, which then calls the 'real' api.

This allows the Front end developers a level of abstraction which they can use to modify the server side responses where required, while keeping the backend api, which may be used for other purposes as well, separate.

Licenciado em: CC-BY-SA com atribuição
scroll top