本文翻译自:What is Express.js?

I am a learner in Node.js . 我是Node.js的学习者。

  1. What is Express.js ? 什么是Express.js ?
  2. What is the purpose of it with Node.js? Node.js的目的是什么?
  3. Why do we actually need Express.js? 为什么我们实际上需要Express.js? How it is useful for us to use with Node.js? 与我们一起使用Node.js有什么用?
  4. What is Redis ? 什么是Redis ? Does it come with Express.js? Express.js附带吗?

#1楼

参考:https://stackoom.com/question/qw2L/什么是Express-js


#2楼

This is over simplifying it, but Express.js is to Node.js what Ruby on Rails or Sinatra is to Ruby . 这过于简化了,但是Express.js对Node.js来说就像Ruby on Rails或Sinatra对Ruby一样 。

Express 3.x is a light-weight web application framework to help organize your web application into an MVC architecture on the server side. Express 3.x是一个轻量级的Web应用程序框架,可帮助您将Web应用程序组织到服务器端的MVC架构中。 You can use a variety of choices for your templating language (like EJS , Jade , and Dust.js ). 您可以为模板语言使用多种选择(例如EJS , Jade和Dust.js )。

You can then use a database like MongoDB with Mongoose (for modeling) to provide a backend for your Node.js application. 然后,您可以将MongoDB之类的数据库与Mongoose一起使用 (用于建模)为Node.js应用程序提供后端。 Express.js basically helps you manage everything, from routes, to handling requests and views. Express.js基本上可以帮助您管理从路由到处理请求和视图的所有内容。

Redis is a key/value store -- commonly used for sessions and caching in Node.js applications. Redis是一个键/值存储-通常用于Node.js应用程序中的会话和缓存。 You can do a lot more with it, but that's what I'm using it for. 您可以使用它做更多的事情,但这就是我使用它的目的。 I use MongoDB for more complex relationships, like line-item <-> order <-> user relationships. 我将MongoDB用于更复杂的关系,例如订单项<->订单<->用户关系。 There are modules (most notably connect-redis) that will work with Express.js. 有些模块(最著名的是connect-redis)可以与Express.js一起使用。 You will need to install the Redis database on your server. 您将需要在服务器上安装Redis数据库。

Here is a link to the Express 3.x guide: https://expressjs.com/en/3x/api.html 这是Express 3.x指南的链接: https : //expressjs.com/en/3x/api.html


#3楼

1) What is Express.js? 1)什么是Express.js?

Express.js is a Node.js framework. Express.js是一个Node.js框架。 It's the most popular framework as of now (the most starred on NPM). 到目前为止,它是最受欢迎的框架(在NPM上最受欢迎)。

.

It's built around configuration and granular simplicity of Connect middleware. 它围绕Connect中间件的配置和精细的简化而构建。 Some people compare Express.js to Ruby Sinatra vs. the bulky and opinionated Ruby on Rails . 有人将Express.js与Ruby Sinatra和笨重而固执的Ruby on Rails进行了比较 。

2) What is the purpose of it with Node.js? 2)Node.js的目的是什么?

That you don't have to repeat same code over and over again. 您不必一遍又一遍地重复相同的代码。 Node.js is a low-level I/O mechanism which has an HTTP module. Node.js是具有HTTP模块的低级I / O机制。 If you just use an HTTP module, a lot of work like parsing the payload, cookies, storing sessions (in memory or in Redis ), selecting the right route pattern based on regular expressions will have to be re-implemented. 如果你只是使用一个HTTP模块,很像解析有效载荷,饼干的工作,存储会话(在内存或Redis的 ),选择基础上,对路由模式正则表达式将不得不重新实现。 With Express.js, it is just there for you to use. 使用Express.js,就可以使用它。

3) Why do we actually need Express.js? 3)为什么我们实际上需要Express.js? How it is useful for us to use with Node.js? 与我们一起使用Node.js有什么用?

The first answer should answer your question. 第一个答案应该回答您的问题。 If no, then try to write a small REST API server in plain Node.js (that is, using only core modules) and then in Express.js. 如果否,则尝试在普通的Node.js(即仅使用核心模块)然后在Express.js中编写小型REST API服务器。 The latter will take you 5-10x less time and lines of code. 后者将使您节省5-10倍的时间和代码行。

What is Redis? 什么是Redis? Does it come with Express.js? Express.js附带吗?

Redis is a fast persistent key-value storage. Redis是一种快速的持久键值存储。 You can optionally use it for storing sessions with Express.js, but you don't need to. 您可以选择使用它来存储与Express.js的会话,但不必这样做。 By default, Express.js has memory storage for sessions. 默认情况下,Express.js具有用于会话的内存存储。 Redis also can be use for queueing jobs, for example, email jobs. Redis也可以用于排队作业,例如电子邮件作业。

Check out my tutorial on REST API server with Express.js . 查看我的Express.js REST API服务器教程 。

MVC but not by itself MVC,但不是本身

Express.js is not an model-view-controller framework by itself. Express.js本身不是一个模型视图控制器框架。 You need to bring your own object-relational mapping libraries such as Mongoose for MongoDB, Sequelize ( http://sequelizejs.com ) for SQL databases, Waterline ( https://github.com/balderdashy/waterline ) for many databases into the stack. 您需要将自己的对象关系映射库(例如用于MongoDB的Mongoose,用于SQL数据库的Sequelize( http://sequelizejs.com ),用于许多数据库的Waterline( https://github.com/balderdashy/waterline )引入数据库中。堆。

Alternatives 备择方案

Other Node.js frameworks to consider ( https://www.quora.com/Node-js/Which-Node-js-framework-is-best-for-building-a-RESTful-API ): 要考虑的其他Node.js框架( https://www.quora.com/Node-js/Which-Node-js-framework-is-best-for-building-a-RESTful-API ):

UPDATE: I put together this resource that aid people in choosing Node.js frameworks: http://nodeframework.com 更新:我整理了此资源,以帮助人们选择Node.js框架: http : //nodeframework.com

UPDATE2: We added some GitHub stats to nodeframework.com so now you can compare the level of social proof (GitHub stars) for 30+ frameworks on one page. UPDATE2:我们在nodeframework.com上添加了一些GitHub统计信息,因此现在您可以在一页上比较30多个框架的社交证明(GitHub星级)水平。

Full-stack: 全栈:

  • http://sailsjs.org http://sailsjs.org

  • http://derbyjs.com/ http://derbyjs.com/

Just REST API: 只是REST API:

  • http://mcavage.github.io/node-restify/ http://mcavage.github.io/node-restify/

Ruby on Rails like: Ruby on Rails像:

  • http://railwayjs.com/ http://railwayjs.com/

  • http://geddyjs.org/ http://geddyjs.org/

Sinatra like: Sinatra喜欢:

  • http://expressjs.com/ http://expressjs.com/

Other: 其他:

  • http://flatironjs.org/ http://flatironjs.org/

  • https://github.com/isaacs/npm-www https://github.com/isaacs/npm-www

  • http://frisbyjs.com/ http://frisbyjs.com/

Middleware: 中间件:

  • http://www.senchalabs.org/connect/ http://www.senchalabs.org/connect/

Static site generators: 静态网站生成器:

  • http://docpad.org http://docpad.org

  • https://github.com/jnordberg/wintersmith https://github.com/jnordberg/wintersmith

  • http://blacksmith.jit.su/ http://blacksmith.jit.su/

  • https://github.com/felixge/node-romulus https://github.com/felixge/node-romulus

  • https://github.com/caolan/petrify https://github.com/caolan/petrify


#4楼

  1. Express.js is a modular web framework for Node.js Express.js是Node.js的模块化Web框架
  2. It is used for easier creation of web applications and services 它用于更轻松地创建Web应用程序和服务
  3. Express.js simplifies development and makes it easier to write secure, modular and fast applications. Express.js简化了开发,并使编写安全,模块化和快速的应用程序变得更加容易。 You can do all that in plain old Node.js, but some bugs can (and will) surface, including security concerns (eg. not escaping a string properly) 您可以在普通的旧Node.js中完成所有操作,但是某些错误可能会(并且会)浮出水面,包括安全问题(例如,未正确转义字符串)
  4. Redis is an in-memory database system known for its fast performance. Redis是一个内存数据库系统,以其快速的性能而闻名。 No, but you can use it with Express.js using a redis client 否,但是您可以使用Redis客户端将它与Express.js结合使用

I couldn't be more concise than this. 我不能比这更简洁。 For all your other needs and information, Google is your friend. 对于您的所有其他需求和信息,Google是您的朋友。


#5楼

  1. What is Express.js? 什么是Express.js?

Express.js is a Node.js web application server framework, designed for building single-page, multi-page, and hybrid web applications. Express.js是一个Node.js Web应用程序服务器框架,旨在用于构建单页,多页和混合Web应用程序。 It is the de facto standard server framework for node.js. 它是node.js的事实上的标准服务器框架。

Frameworks built on Express. 基于Express构建的框架。

Several popular Node.js frameworks are built on Express: 在Express上构建了几种流行的Node.js框架:

LoopBack: Highly-extensible, open-source Node.js framework for quickly creating dynamic end-to-end REST APIs. LoopBack:高度可扩展的开源Node.js框架,用于快速创建动态的端到端REST API。

Sails: MVC framework for Node.js for building practical, production-ready apps. Sails:用于Node.js的MVC框架,用于构建实用的,可用于生产的应用程序。

Kraken: Secure and scalable layer that extends Express by providing structure and convention. Kraken:安全且可扩展的层,通过提供结构和约定来扩展Express。

MEAN: Opinionated fullstack JavaScript framework that simplifies and accelerates web application development. 平均值:有意识的全栈JavaScript框架,可简化并加速Web应用程序的开发。

  1. What is the purpose of it with Node.js? Node.js的目的是什么?
  2. Why do we actually need Express.js? 为什么我们实际上需要Express.js? How it is useful for us to use with Node.js? 与我们一起使用Node.js有什么用?

Express adds dead simple routing and support for Connect middleware, allowing many extensions and useful features. Express增加了简单的路由选择,并支持Connect中间件,从而提供了许多扩展和有用的功能。

For example, 例如,

  • Want sessions? 想要会议吗? It's there 在那
  • Want POST body / query string parsing? 是否需要POST正文/查询字符串解析? It's there 在那
  • Want easy templating through jade, mustache, ejs, etc? 是否想要通过玉器,小胡子,EJS等轻松模板化? It's there 在那
  • Want graceful error handling that won't cause the entire server to crash? 是否需要不会导致整个服务器崩溃的优美的错误处理?

#6楼

ExpressJS is bare-bones web application framework on top of NodeJS. ExpressJS是NodeJS之上的准 Web应用程序框架。

It can be used to build WebApps, RESTFUL APIs etc quickly. 它可以用于快速构建WebApp,RESTFUL API等。

Supports multiple template engines like Jade, EJS. 支持多种模板引擎,例如Jade,EJS。

ExpressJS keeps only a minimalist functionality as core features and as such there are no ORMs or DBs supported as default. ExpressJS仅保留极简功能作为核心功能,因此默认情况下不支持ORM或DB。 But with a little effort expressjs apps can be integrated with different databases. 但是,只要花一点力气,expressjs应用程序就可以与不同的数据库集成。

For a getting started guide on creating ExpressJS apps, look into the following link: 有关创建ExpressJS应用的入门指南,请查看以下链接:

ExpressJS Introductory Tutorial ExpressJS入门教程

什么是Express.js?相关推荐

  1. Express.js 3.0 发布,Node.js 的高性能封装

    Express.js 3.0 发布,这是一个完全改进的版本,详细的改进记录与版本间的比较请看发行说明. Express.js 是对 Node.js 的一个高性能的封装,示例代码: require('e ...

  2. 在express.js上启用HTTPS

    本文翻译自:Enabling HTTPS on express.js I'm trying to get HTTPS working on express.js for node, and I can ...

  3. 30天了解30种技术系列---(1)现代web应用服务器-Express.js

    什么是Express.js Express是一个简洁而灵活的 Node.js Web应用框架, 提供一系列强大特性帮助你创建各种Web应用. 如何使用Express.js 1.创建一个目录(即项目) ...

  4. ⚡如何在2分钟内将GraphQL服务器添加到RESTful Express.js API

    You can get a lot done in 2 minutes, like microwaving popcorn, sending a text message, eating a cupc ...

  5. pacf和acf_如何通过Wordpress API,ACF和Express.js使Wordpress更加令人兴奋

    pacf和acf by Tyler Jackson 泰勒·杰克逊(Tyler Jackson) 如何通过Wordpress API,ACF和Express.js使Wordpress更加令人兴奋 (Ho ...

  6. express-cli入门_使用Express.js入门

    express-cli入门 by Victor Ofoegbu 由Victor Ofoegbu 使用Express.js入门 (Getting off the ground with Express. ...

  7. [译] Node.js, Express.js 搭建 HTTP/2 服务器

    原文:Easy HTTP/2 Server with Node.js and Express.js 作者:Azat Mardan 代码:http2-express 什么是 HTTP/2 现代互联网的 ...

  8. 安装node.js,CoffeeScript,Express.js,mysql,jade

    node-v0.10.5-x86.msi 版本已经包含了节点包管理器 (NPM),安装了这个版本的node.js后,就可以在命令行利用npm命令安装CoffeeScript,Express.js,my ...

  9. heroku_如何使用Express.js和Heroku将应用程序部署到Web

    heroku If you are new to the world of web development, you will spend a lot of time learning how to ...

最新文章

  1. B2B2C网站系统建设的常见误区
  2. [Python陷阱]os.system调用shell脚本获取返回值
  3. 笔记-项目立项管理-项目建议书
  4. php 接口测压,PHP API接口测试小工具
  5. spring配置详解-模块化配置
  6. 软件开发计划_敏捷软件开发实践:估算与计划读书笔记123第21章 关于计划的沟通...
  7. 嵌入式开发板03---看门狗、编写启动代码
  8. 掐头法和去尾法记音标
  9. Leetcode每日一题:197.rising-temperature(上升的温度)
  10. uniapp ---- 添加分页
  11. axios.post请求出错:Request header field content-type is not allowed by Access-Control-Allow-Headers in……
  12. mysql服务器是否支持tcp/ip连接,(3)MySQL客户端与服务端的TCP/IP及socket连接方式-Go语言中文社区...
  13. java生成pdf417条形码_python生成417条形码(PDF417)详解
  14. 关于打印出来的字符串,最后的逗号改为句号的解决办法
  15. webpack 的plugin简单实现 customize-cra
  16. 《私募股权基金投资基础知识》---第五章
  17. u盘推荐知乎_市面上的U盘怎么选择?U盘那个牌子好?
  18. echarts之柱状图(2)
  19. Can‘t bind to ‘ngForOf‘ since it isn‘t a known property of ‘xxx‘
  20. kali-linux-2018.2-i386.iso

热门文章

  1. Android Camera设置setPreviewCallback实现onPreviewFrame接口实时截取每一帧视频流数据
  2. 玩转AppBarLayout,更酷炫的顶部栏
  3. 解决Android 编译出错 找不到android.databinding.ViewDataBinding的类文件
  4. 【Java源码分析】Android-LruCache源码分析
  5. iOS功能-统计平均下班时间
  6. (0082)iOS开发之搭建iOS自动化打包平台(利用Jenkins持续集成iOS项目)
  7. python数据分析numpy_Python数据分析之numpy学习
  8. cmake 版本 arm_在 ARM 架构服务器上编译 Greenplum6并制作rpm安装包
  9. 复制订阅服务器和 AlwaysOn 可用性组 (SQL Server)
  10. HDU 2149 Public Sale