Node.js Web 应用程序示例/教程
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3823403/
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 Web Application examples/tutorials
提问by Kris Erickson
So I finished watching Douglas Crockford's excellent series on Javascript, and in the final episode (so far), loopagehe lays out why Node.js is a near perfect solution for server side code.
所以我看完了 Douglas Crockford 关于 Javascript 的优秀系列,在最后一集中(到目前为止),循环他阐述了为什么 Node.js 是服务器端代码的近乎完美的解决方案。
He talks about keeping state, not in the database, but in closures running in Node.js, he also states that templating systems (like JSP, PHP, and ASP) are a poor abstraction for more complicated Web Applications and that node.js provides a solution to this.
他谈到保持状态,而不是在数据库中,而是在 Node.js 中运行的闭包中,他还指出模板系统(如 JSP、PHP 和 ASP)对于更复杂的 Web 应用程序来说是一个糟糕的抽象,而 node.js 提供对此的解决方案。
And I am ready to buy in, but I can't find any examples of Web Applications using this pattern, or any books or tutorials about how to go about doing this. I am not talking about a simple application, but something that would use the patterns that Crockford spoke of in his talk. Anyone know where I can find some tutorials/examples of Web Applications written in Node.js (and yes I know about Geddyand ExpressJs, but they don't seem to follow the radically different patterns that Crockford was speaking of, and were more like getting a Railsy experience on Node.js).
我准备购买,但我找不到任何使用此模式的 Web 应用程序示例,也找不到有关如何执行此操作的任何书籍或教程。我不是在谈论一个简单的应用程序,而是要使用 Crockford 在他的演讲中谈到的模式的东西。任何人都知道我在哪里可以找到一些用 Node.js 编写的 Web 应用程序的教程/示例(是的,我知道Geddy和ExpressJs,但它们似乎没有遵循 Crockford 所说的完全不同的模式,更像是在 Node.js 上获得 Railsy 体验)。
[Note from 3 years in the future: It seems like Express, Geddy, Sails, Krakenet all are re-implementations of the Rails/Symfony/Spring frameworks from Ruby/PHP/Java. Whereas things like Hoodieand Meteorare attempts at a whole new paradigm. KOAlooks interesting, but is a ways away from being usable, but looks like it is building on the strengths of javascript with the history of MVC applications of the past. 3 years on and it is still exciting times for Nodejs, even if it is no longer the new hotness. At least there are a lot of real world examples of Node in use now...
[未来 3 年的注意事项:似乎Express、Geddy、Sails、Kraken等都是 Ruby/PHP/Java 的 Rails/Symfony/Spring 框架的重新实现。而像Hoodie和Meteor这样的东西则是对全新范式的尝试。 KOA看起来很有趣,但离可用还有一段距离,但看起来它是建立在 javascript 的优势和过去 MVC 应用程序的历史之上的。3 年过去了,对于 Nodejs 来说仍然是激动人心的时刻,即使它不再是新的热点。至少现在有很多实际使用的 Node 示例......
采纳答案by JeanNiBee
I would suggest you check out the various tutorials that are coming out lately. My current fav is:
我建议您查看最近发布的各种教程。我目前最喜欢的是:
Hope this helps.
希望这可以帮助。
回答by Chris Bloom
The Node Knockoutcompetition wrapped up recently, and many of the submissions are available on github. The competition site doesn't appear to be working right now, but I'm sure you could Google up a few entries to check out.
该节点淘汰赛比赛日前结束了,许多意见都可以在github上。比赛网站现在似乎无法运行,但我相信您可以在 Google 上搜索一些条目进行查看。
回答by Varun Singh
DailyJS has a good tutorial (long series of 24 posts) that walks you through all the aspects of building a notepad app (including all the possible extras).
DailyJS 有一个很好的教程(包含 24 篇文章的长系列),它会引导您了解构建记事本应用程序的所有方面(包括所有可能的附加功能)。
Heres an overview of the tutorial: http://dailyjs.com/2010/11/01/node-tutorial/
以下是本教程的概述:http: //dailyjs.com/2010/11/01/node-tutorial/
And heres a link to all the posts: http://dailyjs.com/tags.html#nodepad
这是所有帖子的链接:http: //dailyjs.com/tags.html#nodepad
回答by Ivo Wetzel
Update
更新
Dav Glass from Yahoo has given a talk at YuiConf2010 in November which is now available in Video from.
雅虎的 Dav Glass 在 11 月的 YuiConf2010 上发表了演讲,现在可以从.
He shows to great extend how one can use YUI3 to render out widgets on the server side an make them work with GET requests when JS is disabled, or just make them work normally when it's active.
他展示了如何使用 YUI3 在服务器端渲染小部件,并在 JS 禁用时使它们与 GET 请求一起工作,或者在 JS 处于活动状态时使它们正常工作。
He also shows examples of how to use server side DOM to apply style sheets before rendering and other cool stuff.
他还展示了如何在渲染和其他很酷的东西之前使用服务器端 DOM 应用样式表的示例。
The demos can be found on his GitHub Account.
可以在他的GitHub 帐户上找到演示。
The part that's missing IMO to make this really awesome, is some kind of underlying storage of the widget state. So that one can visit the page without JavaScript and everything works as expected, then they turn JS on and now the widget have the same state as before but work without page reloading, then throw in some saving to the server + WebSockets to sync between multiple open browser.... and the next generation of unobtrusive and gracefully degrading ARIA's is born.
缺少 IMO 使这真的很棒的部分是小部件状态的某种底层存储。这样就可以在没有 JavaScript 的情况下访问页面并且一切都按预期工作,然后他们打开 JS,现在小部件具有与以前相同的状态但无需重新加载页面即可工作,然后将一些保存到服务器 + WebSockets 以在多个服务器之间同步打开浏览器......,下一代不引人注目且优雅降级的 ARIA 诞生了。
Original Answer
原答案
Well go ahead and built it yourself then.
那么继续吧,然后自己构建它。
Seriously, 90% of all WebApps out there work fine with a REST approach, of course you could do magical things like superior user tracking, tracking of downloads in real time, checking which parts of videos are being watched etc.
说真的,90% 的 Web 应用程序在使用 REST 方法时可以正常工作,当然你可以做一些神奇的事情,比如高级用户跟踪、实时下载跟踪、检查正在观看的视频部分等。
One problem is scalability, as soon as you have more then 1 Node process, many (but not all) of the benefits of having the data stored between requests go away, so you have to make sure that clients always hit the same process. And even then, bigger things will yet again need a database layer.
一个问题是可扩展性,一旦您有超过 1 个节点进程,在请求之间存储数据的许多(但不是全部)好处就会消失,因此您必须确保客户端始终命中相同的进程。即便如此,更大的事情将再次需要一个数据库层。
Node.js isn't the solution to everything, I'm sure people will build really great stuff in the future, but that needs some time, right now many are just porting stuff over to Node to get things going.
Node.js 不是所有问题的解决方案,我相信人们将来会构建出非常棒的东西,但这需要一些时间,现在很多人只是将东西移植到 Node 上来让事情顺利进行。
What (IMHO) makes Node.js so great, is the fact that it streamlines the Development process, you have to write less code, it works perfectly with JSON, you loose all that context switching.
什么(恕我直言)让 Node.js 如此伟大,是因为它简化了开发过程,你必须编写更少的代码,它与 JSON 完美配合,你失去了所有上下文切换。
I mainly did gaming experiments so far, but I can for sure say that there will be many cool multi player (or even MMO) things in the future, that use both HTML5 and Node.js.
到目前为止,我主要是做游戏实验,但我可以肯定地说,未来会有很多很酷的多人(甚至 MMO)游戏,同时使用 HTML5 和 Node.js。
Node.js is still gaining traction, it's not even near to the RoR Hype some years ago (just take a look at the Node.js tag here on SO, hardly 4-5 questions a day).
Node.js 仍然受到关注,它甚至还没有接近几年前的 RoR 炒作(只需看看 SO 上的 Node.js 标签,每天几乎没有 4-5 个问题)。
Rome (or RoR) wasn't built over night, and neither will Node.js be.
Rome(或 RoR)不是一夜之间建成的,Node.js 也不会。
Node.js has all the potential it needs, but people are still trying things out, so I'd suggest you to join them :)
Node.js 拥有它需要的所有潜力,但人们仍在尝试,所以我建议你加入他们:)
回答by mgutz
The closest thing is likely Dav Glass's experimental work using node.js, express and YUI3. Basically, he explains how YUI3 is used to render markup on the server side, then sent to the client where binding to event and data occurs. The beauty is YUI3 is used as-is on both the client and the server. Makes a lot of sense. The one big issue is there is not yet a production ready server-side DOM library.
最接近的可能是 Dav Glass 使用 node.js、express 和 YUI3 的实验工作。基本上,他解释了如何使用 YUI3 在服务器端呈现标记,然后将其发送到发生事件和数据绑定的客户端。美妙的是 YUI3 在客户端和服务器上都按原样使用。很有道理。一个大问题是还没有一个生产就绪的服务器端 DOM 库。

