end*_*ssC 5 project-structure node.js express
我正在制作可伸缩的REST-API,但是我几乎找不到关于大型应用程序的高级node.js应用程序结构方面的文章,因为它们中的大多数都使用简单的入门项目。
我的问题:以下解决方案的最佳结构是什么?
1.将路线保存在单独的文件夹中:
src
product
index.js
product.spec.js
routes
index.js
product.js
user.js
user
index.js
user.spec.js
Run Code Online (Sandbox Code Playgroud)
2.将路由放入其相应的文件夹中:
src
product
index.js
product.route.js
product.spec.js
user
index.js
user.route.js
user.spec.js
Run Code Online (Sandbox Code Playgroud)
使用index.js
文件中的路由。
有更好的解决方案吗?
任何有关高级,可伸缩节点项目结构的文章将不胜感激!
由于这是我的意见问题:
我的构建将所有内容从 迁移src
到dist
. 有些是编译的,有些只是复制的。然后我直接从文件夹运行dist
。
src
api
<api files/folders>
lib
<common lib files/folders>
routes
<Route files (app.use, app.get, etc.)>
static
<static css, images, script, etc.>
<I do not include src code that is compiled in any way>
ui
<LESS, SASS, JS, etc that will be compiled, combined, packed, etc>
views
<ejs files>
app.js
Run Code Online (Sandbox Code Playgroud)
中的内容src/ui/**
被编译并放入dist/static/**
.
归档时间: |
|
查看次数: |
819 次 |
最近记录: |