MEAN stack项目结构疑惑

MEAN stack project structure doubts

我正在开发一个基于 MEAN 堆栈的应用程序,我对文件结构有一些疑问,我正在考虑三个选项:

我在网上搜索过,但我一无所获

就我个人而言,我会选择列表中的最后一个选项:“Frontend(Angular) 和 REST API 均由 NodeJS 服务,除以路由(/page 和 /api)".

我最近在这里看到一个 说:

When you serve a node.js app note that you are the author of your own web server. Any potential bug in your app is a directly exploitable bug on the internet. Some people are (justifiably) not comfortable with this.

Adding a layer of Apache or Nginx in front of your node.js app means you have a battle-tested, security-hardened piece of software on the live internet as an interface to your app. It adds a tiny bit of latency (the reverse proxying) but most consider it worth it.

This used to be the standard advice in the early days of node.js. But these days there are also sites and web services that exposes node.js directly to the internet. The http.Server module is now fairly well battle-tested on the internet to be trusted.

关于安全性,这告诉我你不应该在你的 Node 应用程序前需要 Apache 或 Nginx 等东西。

就文件结构的观点而言,我会选择此选项也只是因为我在许多地方工作过,他们已经这样做了并且它使与 API 的交互变得简单,对于想要使用 API 的内部和外部各方而言,可预测且易于接近(我是使用 api.mydomain.com 或 mydomain.com/api/ 的公司的忠实粉丝)。

不过我猜这取决于偏好。