我想知道使用 Node.js (express.js) 是否是构建完整网站的最佳选择。我一直在使用 Rails + Node.js,我想知道这是否仍然是最好的选择,或者我是否应该完全转向 Node.js。
是否有完全使用 node.js 构建的网站?我想它一定缺少 Rails 提供的许多东西。
最佳答案
I imagine it must lack many things Rails offers.
我在下面给出了一个简短的列表,但我想知道您可能缺少什么,我认为(几乎可以肯定)我们可以在 node.js 上为您提供一些替代方案。
模块
node.js 变得非常完整,我认为您可以仅使用 node.js 运行整个站点,例如以下模块。我假设你知道 npm
。如果不是,我真的建议你用谷歌搜索并学习。要搜索 npm,您可以使用 http://search.npmjs.org :
网络框架:
High performance, high class web development for Node.js
https://github.com/visionmedia/expressSocket.IO aims to make realtime apps possible in every browser and mobile device, blurring the differences between the different transport mechanisms. https://github.com/learnboost/socket.io-node
我相信通过这两个网络框架,您可以创建很多网站。例如 express 是一个非常强大的 web 框架,并且支持很多很酷的东西,比如:
- session支持。
- 非常强大template engines .例如,我喜欢 Jade 。您还可以轻松地在客户端和服务器之间多次共享这些内容。
- 优秀routing .
仅举几例。
数据库:
Redis is an open source, advanced key-value store. It is often referred to as a data structure server since keys can contain strings, hashes, lists, sets and sorted sets.
https://github.com/mranney/node_redisMongoDB (from "humongous") is a scalable, high-performance, open source, document-oriented database. Mongoose is a MongoDB object modeling tool designed to work in an asychronous environment.
https://github.com/learnboost/mongoose/
使用这两个数据库,我认为您应该能够完成大部分任务。好消息是 Redis 非常快速/简单的高级 KV 存储(内存中的数据集/也支持 VM)并支持复制,而 Mongodb 更完整(比 redis 慢)并且还支持分片。
认证:
- Authentication and authorization (password, facebook, & more) for your node.js Connect and Express apps.
https://github.com/bnoguchi/everyauth
就像我之前说的,只有这些模块你才能走得更远。
关于javascript - Node.js 是构建完整网站的好选择吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6404555/