How to organize large Node.js projects

后端 未结 6 944
春和景丽
春和景丽 2021-01-29 20:22

What are some good ways to organize large Node.js projects?

For example, an app making use of both express.js and socket.io? This would include both application logical

6条回答
  •  一整个雨季
    2021-01-29 20:40

    If you don't mind, you can always learn typescript and go for https://nestjs.com/

    If you want to stick with JS I strongly recommend to use onion architecture. The best practice is to keep separated business logic, controllers, even libraries (they should be wrapped inside of some classes / helpers) - just in case, if you will have to migrate to another library (different CSV parser etc.).

    With onion architecture, you don't care from where requests comes from, there won't be a lot of changes to add even some message broker.

    Also try this one https://en.wikipedia.org/wiki/Domain-driven_design

    ESLint may help with proper project organization.

提交回复
热议问题