Node.js Web 应用程序示例/教程

发布于 2024-09-25 18:14:02 字数 1597 浏览 6 评论 0原文

所以我看完了 Douglas Crockford 关于 Javascript 的精彩系列,在最后一集中(到目前为止),loopage 他阐述了为什么 Node.js 是服务器端代码近乎完美的解决方案。

他谈到了保持状态,不是在数据库中,而是在 Node.js 中运行的闭包中,他还指出,模板系统(如 JSP、PHP 和 ASP)对于更复杂的 Web 应用程序来说是一个糟糕的抽象,而 Node.js 提供了对此的解决方案。

我已经准备好接受,但我找不到任何使用此模式的 Web 应用程序示例,也找不到任何有关如何执行此操作的书籍或教程。我不是在谈论简单的应用程序 ,但是会使用克罗克福德在他的演讲中提到的模式。任何人都知道我在哪里可以找到一些用 Node.js 编写的 Web 应用程序的教程/示例(是的,我知道 GeddyExpressJs,但它们似乎并没有遵循 Crockford 所说的完全不同的模式,而更像在 Node.js 上获得 Railsy 体验)。

[未来3年的注意事项:看起来像ExpressGeddyKraken 等都是来自 Ruby/PHP/Java 的 Rails/Symfony/Spring 框架的重新实现。而像 连帽衫Meteor 是对全新范式的尝试。 KOA 看起来很有趣,但离可用还有一段距离,但看起来它是建立在 javascript 的优势之上的过去的 MVC 应用程序的历史。 3 年过去了,对于 Nodejs 来说,它仍然是令人兴奋的时代,即使它不再是新的热点。至少现在有很多 Node 的实际例子在使用......

So I finished watching Douglas Crockford's excellent series on Javascript, and in the final episode (so far), loopage he lays out why Node.js is a near perfect solution for server side code.

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.

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 Geddy and 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).

[Note from 3 years in the future: It seems like Express, Geddy, Sails, Kraken et all are re-implementations of the Rails/Symfony/Spring frameworks from Ruby/PHP/Java. Whereas things like Hoodie and Meteor are attempts at a whole new paradigm. KOA looks 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...

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

隐诗 2024-10-02 18:14:02

我建议您查看最近发布的各种教程。我目前最喜欢的是:

http://nodetuts.com/

希望这会有所帮助。

I would suggest you check out the various tutorials that are coming out lately. My current fav is:

http://nodetuts.com/

Hope this helps.

往事风中埋 2024-10-02 18:14:02

Node Knockout 竞赛最近结束,许多提交的内容都可以在 github 上找到。该竞赛网站目前似乎无法运行,但我相信您可以通过 Google 搜索一些条目来查看。

The Node Knockout competition 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.

入画浅相思 2024-10-02 18:14:02

DailyJS 有一个很好的教程(包含 24 篇文章的长系列),它将引导您完成构建记事本应用程序的所有方面(包括所有可能的附加功能)。

以下是本教程的概述: http://dailyjs.com/2010/11/01 /node-tutorial/

这是所有帖子的链接:http://dailyjs.com /tags.html#nodepad

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).

Heres an overview of the tutorial: http://dailyjs.com/2010/11/01/node-tutorial/

And heres a link to all the posts: http://dailyjs.com/tags.html#nodepad

秋意浓 2024-10-02 18:14:02

更新

来自雅虎的 Dav Glass 于 11 月在 YuiConf2010 上发表了演讲,该演讲现已在 视频来自

他很好地展示了如何使用 YUI3 在服务器端渲染小部件,并在 JS 禁用时使它们与 GET 请求一起工作,或者在 JS 处于活动状态时使它们正常工作。

他还展示了如何使用服务器端 DOM 在渲染之前应用样式表和其他很酷的东西的示例。

这些演示可以在他的 GitHub 帐户 上找到。

IMO 缺少的部分是小部件状态的某种底层存储。这样就可以在没有 JavaScript 的情况下访问该页面,并且一切都按预期工作,然后他们打开 JS,现在小部件具有与以前相同的状态,但无需重新加载页面即可工作,然后将一些保存到服务器 + WebSockets 以在多个之间同步打开浏览器......下一代不引人注目且优雅的 ARIA 就诞生了。

原始答案

那么就自己构建吧。

说真的,90% 的 Web 应用程序都可以通过 REST 方法正常工作,当然您可以做一些神奇的事情,例如高级用户跟踪、实时下载跟踪、检查正在观看视频的哪些部分等。

其中一个问题是可扩展性,一旦您拥有超过 1 个节点进程,在请求之间存储数据的许多(但不是全部)好处就会消失,因此您必须确保客户端始终访问同一进程。即便如此,更大的事情将再次需要数据库层。

Node.js 并不是所有问题的解决方案,我确信人们将来会构建出真正伟大的东西,但这需要一些时间,现在许多人只是将东西移植到 Node 来让事情顺利进行。

(恕我直言)Node.js 之所以如此出色,是因为它简化了开发过程,您必须编写更少的代码,它与 JSON 完美配合,您可以摆脱所有上下文切换。

到目前为止,我主要进行游戏实验,但我可以肯定地说,未来将会有许多很酷的多人游戏(甚至 MMO)事物,它们同时使用 HTML5 和 Node.js。

Node.js 仍然受到关注,它甚至还没有接近几年前的 RoR Hype(只需看看这里的 Node.js 标签,一天几乎没有 4-5 个问题)。

Rome(或 RoR)不是一朝一夕建成的,Node.js 也不会。

Node.js 拥有它所需的所有潜力,但人们仍在尝试,所以我建议您加入他们:)

Update

Dav Glass from Yahoo has given a talk at YuiConf2010 in November which is now available in Video from.

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.

He also shows examples of how to use server side DOM to apply style sheets before rendering and other cool stuff.

The demos can be found on his GitHub Account.

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.

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.

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.

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.

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.

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.

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).

Rome (or RoR) wasn't built over night, and neither will Node.js be.

Node.js has all the potential it needs, but people are still trying things out, so I'd suggest you to join them :)

少钕鈤記 2024-10-02 18:14:02

最接近的可能是 Dav Glass 使用 node.js、express 和 YUI3 的实验性工作。基本上,他解释了如何使用 YUI3 在服务器端呈现标记,然后将其发送到发生事件和数据绑定的客户端。优点是 YUI3 在客户端和服务器上都按原样使用。很有道理。一个大问题是还没有一个可用于生产的服务器端 DOM 库。

截屏

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.

screencast

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文