Express vs Nestjs项目结构

发布于 2025-02-09 11:07:19 字数 503 浏览 0 评论 0原文

我计划在节点中构建一个REST API,该API将由React-Nove Mobile应用程序(使用JWT令牌)和ReactJS Web应用程序(使用Sessions/sessions/http-folly cookies)消费。您是否建议我直接在Express或使用Nestjs之类的框架中写这件?

  1. 考虑到管理,易于管理,自动化,托管等,我应该如何构建/架构项目以满足上述要求?
  2. 您会考虑直接在服务器上直接在运行节点上扩展节点应用程序吗?有表现增长吗?
  3. 我应该将项目分解为3个存储库即:
  4.   REST API |后端webui(reactjs)|移动应用(反应)
     
  5.   
  6.   REST API +后端WebUI(reactjs)|移动应用(反应)
     

欢迎您的想法/建议,请提前感谢。

I am planning to build a rest api in node that will be consumed by a react-native mobile app(using JWT tokens) and reactJS web app(admin UI using sessions/http-only cookies). Would you advise me to write this directly in express or use a framework like nestJS?

  1. How should I structure/architect the project to meet the above requirements taking into consideration, ease of Management, autoscaling, hosting, etc?
  2. Would you consider dockerizing the node application over running node directly on the server? is there any performance gains?
  3. should I break the project into 3 repos ie:
  4. rest api | backend webUI(reactJS) | mobile app (react-native)
    
  5. or
    
  6. rest api + backend webUI(reactJS) | mobile app (react-native)
    

Ideas/advises are welcome please, thank in advance.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

紙鸢 2025-02-16 11:07:19

我将尝试根据我在两者中的工作经验来回答:

  1. 项目的结构/体系结构取决于您是否在API或团队中单独工作(Express可以为您提供代码的自由,但您喜欢的是一场噩梦并且与一个大型团队试图维护它变得更加复杂),Nestjs有一个结构可供您和您的团队(如果MVC模型为您的用例完成工作),
  2. docker使用均可轻松地部署两者(如果您知道自己在做什么),并且在运行多个实例时可以具有更好的性能。 恢复更难
  3. CATCE在生产服务器中使用Docker数据库备份和 他们很容易将错误域分开,但是与您的团队交谈并提供文档,以了解您在休息服务中想要的内容,并且WebUI不会与移动应用程序接触到同一用户群,那么这并不重要

I'll try to answer based on my work experience in both:

  1. Structure/architecture of the project depends if you are working alone on the API or in teams (express gives you freedom in code however you like but it's a nightmare if your application grows and gets bigger in complexity with a big team trying to maintain it), NestJS has a structure to follow for you and your team (if MVC model gets the job done for your use case)
  2. Docker use is for ease of deployment for both (if you know what you are doing) and can have better performance when running multiple instances. the catch is in the production server with a docker database backup and recovery are harder and if you need migration/restructure after deployment in prod welp...you gonna cry
  3. I always separate (API | web UI | mobile app) so I can debug them easily separate domains of errors but talk to your team and provide docs for what they want in the Rest service if you are alone and the WebUI is not exposed to the same user base as the mobile app then it doesn't matter really
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文