javascript node.js 样板 + 最佳实践
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11922773/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
node.js boilerplate + best practices
提问by user1271518
I'm new to node.js, just starting..
我是 node.js 的新手,刚刚开始..
i'm after a good node.js boilerplate and best practices such as coding design pattrens (for example Dependency injection, etc.. I've read JS design pattrens by Douglas Crockford not once.. but would like to see the differences for node) name-spacing - with directory structure, etc..
我正在寻找一个好的 node.js 样板和最佳实践,例如编码设计模式(例如依赖注入等。 ) 名称间距 - 具有目录结构等。
regarding node.js stack as far as i know:
据我所知,关于 node.js 堆栈:
- express - must
- async - must (flow control)
- dnode - ?
- socket.io - websocket
- nowjs - would love to use it , but as i understand the scale version won't be free ("we'll soon be licensing a distributed version of NowJS currently under development. Contact us at [email protected]")
- underscore + backbone - ?
- DB layer - ?
- templating - i use handleBars - jquery is a must
- require.js - (i don't want to use commonJS... not sure how the integration on the server works)
- 快递 - 必须
- 异步 - 必须(流量控制)
- 节点 - ?
- socket.io - websocket
- nowjs - 很想使用它,但据我所知,规模版本不会免费(“我们很快就会授权目前正在开发的 NowJS 的分布式版本。通过 [email protected] 联系我们”)
- 下划线 + 主干 - ?
- 数据库层 - ?
- 模板 - 我使用 handleBars - jquery 是必须的
- require.js - (我不想使用 commonJS ... 不确定服务器上的集成如何工作)
So what to add/ remove from the libs list?, where can i find a professional boilerplate? and any other tips relating to it.
那么从库列表中添加/删除什么?,我在哪里可以找到专业的样板?以及与此相关的任何其他提示。
Thanks in advance!
提前致谢!
采纳答案by irakli
IMHO, for a project skeleton, more important than which modules to include (those are easy to install with npm, anyway) is how to structure your project, how to use cluster properly and do hot-reloading for dev + process monitoring in production.
恕我直言,对于项目框架来说,比要包含哪些模块(这些模块很容易用 npm 安装,无论如何)更重要的是如何构建你的项目,如何正确使用集群以及在生产中为开发 + 流程监控进行热重载。
You can see some of those tricks at: http://nodebootstrap.comhttps://github.com/inadarei/nodebootstrap
您可以在以下位置查看其中一些技巧:http: //nodebootstrap.comhttps://github.com/inadarei/nodebootstrap
Edit: dead link as of 12/03/14
编辑:截至 14 年 3 月 12 日的死链接
回答by Doobi
I've been looking for a node boilerplate project, and came across this, it's seems to be the most favourited on GitHub with almost 10x the stars of any of the others
我一直在寻找一个节点样板项目,并遇到了这个,它似乎是 GitHub 上最受欢迎的项目,几乎是其他任何项目的 10 倍
回答by Rudolf Meijering
I'm a bit late, but hopefully this will help someone else.
我有点晚了,但希望这会对其他人有所帮助。
One of the shortcomings of nodebootstrap (and almost every other node boilerplate project out there) is that it doesn't provide any boilerplate code for getting started with Backbone.js
nodebootstrap(以及几乎所有其他节点样板项目)的缺点之一是它不提供任何样板代码来开始使用 Backbone.js
Similarly there are great Backbone.js boilerplate projects, some (see Yeoman.io), even include little node development servers, but these are hard to expand into a full on backend/frontend solution for building a webapp.
同样,也有很棒的 Backbone.js 样板项目,有些(参见Yeoman.io),甚至包括很少的节点开发服务器,但是这些很难扩展为构建 web 应用程序的完整后端/前端解决方案。
I therefore started webapp-boilerplatewhich uses grunt-tasks for compilation and server reloads on code changes. It's still a work in progress, but should get you started quickly.
因此,我启动了webapp-boilerplate,它使用 grunt-tasks 进行编译,并在代码更改时重新加载服务器。它仍在进行中,但应该可以让您快速入门。
回答by bryce
I think the Backbone-Require-Boilerplate is pretty impressive.
我认为 Backbone-Require-Boilerplate 令人印象深刻。
https://github.com/BoilerplateMVC/Backbone-Require-Boilerplate
https://github.com/BoilerplateMVC/Backbone-Require-Boilerplate
Includes Backbone, Lodash, Require.js, Almond.js, jQuery, jQueryUI, jQuery Mobile, Twitter Bootstrap, Jasmine, and Grunt. I was up and running in minutes and it's made with an appreciation for the differences in prod vs dev environments.
包括 Backbone、Lodash、Require.js、Almond.js、jQuery、jQueryUI、jQuery Mobile、Twitter Bootstrap、Jasmine 和 Grunt。我在几分钟内就启动并运行了它,它感谢生产环境与开发环境的差异。