【发布时间】:2012-10-13 17:31:06
【问题描述】:
我正在启动一个 express.js 项目。我想看看退出大型应用程序的代码,尤其是它们的文件系统结构。有人知道使用 express.js 并且在 github 上的应用吗?
【问题讨论】:
我正在启动一个 express.js 项目。我想看看退出大型应用程序的代码,尤其是它们的文件系统结构。有人知道使用 express.js 并且在 github 上的应用吗?
【问题讨论】:
github 上有大量使用 express 的应用程序。对于大型项目,您可以查看 krakenjs.com。这不是一个真正的应用程序,而更像是一个由 paypal 从 java 切换到 node.js 时创建的应用程序的结构。
如果您想使用 angular.js 和 mongodb,您还可以查看更全栈的应用程序结构,例如 mean.io 或 meanjs.org。即使您不知道,您也可以了解他们如何构建代码。
【讨论】:
查看可以在 github repository 找到的 express 示例。如果你喜欢 MVC,那么还有一个 example 。它们让您初步了解如何构建应用程序。
有关如何构建您的应用程序的更多信息,请参见“我应该如何构建我的应用程序?”下的 faq。
【讨论】:
这是我的布局。
./myapp
./public -- static files
./modules -- modules I made for reusability
./routes -- like controllers
./log -- app log file
./views -- ejs views
./config -- config.development.js, config.global.js
./templates -- email templates (text/html in ejs)
./pid -- for server
./init -- git post-receive hook for deploy
./models -- mongoose schemas
【讨论】:
这不是一个非常大规模的项目,但它为您提供了有关如何构建应用程序的基本概念,它是一个 REST API https://github.com/khurrumqureshi/BotnikServer
【讨论】:
在我的快递应用中,我或多或少有这样的结构:
project
|--app.js
|--bin
| `--shell scripts and stuff*
|--docroot
| `--static files, etc*
|--node_modules
| `--npm downloads go here*
|--lib
| |--vendor
| | `--jar files and stuff*
| |--my-custom-middleware1.js
| `--my-custom-middleware2.js
|--package.json
|--README.md
`--templates
`--a bunch of templates*
可以很好地满足我的需要。
【讨论】:
【讨论】:
看看我对ExpressJS How to structure an application 的回答。您还可以查看repo for my own web site,它虽然不大也不令人兴奋,但它是一个快速应用程序,并且具有非常健全的文件系统和代码组织方案 (IMHO)。
当然,浏览list of ExpressJS applications on the main Express site。不确定哪些是开源的,但请看一看。
【讨论】: