尽管我很了解JavaScript,但我还是不明白Node.js生态系统中的这三个项目到底是做什么的。是不是有点像《Rails’Rack》?有人能解释一下吗?
当前回答
愚蠢的简单答案
Connect和Express是nodejs的web服务器。与Apache和IIS不同,它们都可以使用相同的模块,称为“中间件”。
其他回答
middleware as the name suggests actually middleware is sit between middle.. middle of what? middle of request and response..how request,response,express server sit in express app in this picture you can see requests are coming from client then the express server server serves those requests.. then lets dig deeper.. actually we can divide this whole express server's whole task in to small seperate tasks like in this way. how middleware sit between request and response small chunk of server parts doing some particular task and passed request to next one.. finally doing all the tasks response has been made.. all middle ware can access request object,response object and next function of request response cycle..
这是一个很好的例子来解释中间件在表达YouTube视频中间件
Connect为常见的HTTP服务器功能(如会话管理、身份验证、日志记录等)提供了“更高级别”的api。Express是建立在具有高级功能(类似Sinatra)的Connect之上的。
相关信息,特别是如果您正在使用NTVS与Visual Studio IDE一起工作。NTVS将NodeJS和Express工具,脚手架,项目模板添加到Visual Studio 2012, 2013。
此外,将ExpressJS或Connect作为“WebServer”调用的措辞是不正确的。您可以使用或不使用它们来创建一个基本的WebServer。一个基本的NodeJS程序也可以使用http模块来处理http请求,从而成为一个基本的web服务器。
Node.js本身提供了一个HTTP模块,其createServer方法返回一个对象,您可以使用该对象响应HTTP请求。该对象继承了http。服务器原型。
愚蠢的简单答案
Connect和Express是nodejs的web服务器。与Apache和IIS不同,它们都可以使用相同的模块,称为“中间件”。
推荐文章
- 很好的初学者教程socket.io?
- CALL_AND_RETRY_LAST分配失败-进程内存不足
- 在Ubuntu上安装Node.js
- 使用express.js代理
- Node -使用NODE_MODULE_VERSION 51根据不同的Node.js版本编译
- RabbitMQ / AMQP:单队列,同一消息的多个消费者?
- Node.js同步执行系统命令
- 禁用包的postinstall脚本
- Node.js上的html解析器
- 错误:无法找到模块“webpack”
- 在node.js中使用async / await文件系统
- NodeJS -用NPM安装错误
- 如何为本地安装npm包设置自定义位置?
- 回调函数来处理管道的完成
- Express函数中的“res”和“req”参数是什么?