[英]what is nodejs best practice file structure
Can you give examples of how can i structure my nodejs server should I group them like this你能举例说明我应该如何构建我的 nodejs 服务器吗?我应该像这样对它们进行分组吗?
| - controllers - | users
| | products
|
|
| -models - | users
| | products
or like this或者像这样
| -Product |controller
| |model
| -users |controller
| |model
can you give me where to learn the best practice structure and more info about other files structure ways for an api server你能告诉我在哪里可以了解最佳实践结构以及有关 api 服务器的其他文件结构方式的更多信息吗
It is always better to structure your file projects based on packages not entities:基于包而不是实体来构建文件项目总是更好:
| controllers: | product
| | user
|
| models: | product
| | user
|
| middlewares: | authentication
Here is a article for further explanation: https://dreamix.eu/blog/frontpage/node.js-project-structure-a-short-guide这里有一篇文章进一步解释: https://dreamix.eu/blog/frontpage/node.js-project-structure-a-short-guide
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.