diff --git a/_includes/api/en/3x/app.md b/_includes/api/en/3x/app.md index 747c01b2..0d15c491 100644 --- a/_includes/api/en/3x/app.md +++ b/_includes/api/en/3x/app.md @@ -1,4 +1,4 @@ -

Application

+

Application

{% include api/en/3x/app-set.md %} diff --git a/_includes/api/en/3x/express.md b/_includes/api/en/3x/express.md index 5b82283a..910bb3b0 100644 --- a/_includes/api/en/3x/express.md +++ b/_includes/api/en/3x/express.md @@ -1,4 +1,4 @@ -

express()

+

express()

Creates an Express application. The `express()` function is a top-level function exported by the _express_ module. diff --git a/_includes/api/en/3x/middleware.md b/_includes/api/en/3x/middleware.md index 96218054..001790ac 100644 --- a/_includes/api/en/3x/middleware.md +++ b/_includes/api/en/3x/middleware.md @@ -1,4 +1,4 @@ -

Middleware

+

Middleware

{% include api/en/3x/mw-basicAuth.md %} diff --git a/_includes/api/en/3x/req.md b/_includes/api/en/3x/req.md index fcbc8930..d8f10b8a 100644 --- a/_includes/api/en/3x/req.md +++ b/_includes/api/en/3x/req.md @@ -1,4 +1,4 @@ -

Request

+

Request

The `req` object is an enhanced version of Node's own request object and supports all [built-in fields and methods](https://nodejs.org/api/http.html#http_class_http_incomingmessage). diff --git a/_includes/api/en/3x/res.md b/_includes/api/en/3x/res.md index 1c72c6fe..e6813f66 100644 --- a/_includes/api/en/3x/res.md +++ b/_includes/api/en/3x/res.md @@ -1,4 +1,4 @@ -

Response

+

Response

The `res` object is an enhanced version of Node's own response object and supports all [built-in fields and methods](https://nodejs.org/api/http.html#http_class_http_serverresponse). diff --git a/_includes/api/en/4x/app.md b/_includes/api/en/4x/app.md index b4688f39..1ae17699 100644 --- a/_includes/api/en/4x/app.md +++ b/_includes/api/en/4x/app.md @@ -1,4 +1,4 @@ -

Application

+

Application

The `app` object conventionally denotes the Express application. Create it by calling the top-level `express()` function exported by the Express module: diff --git a/_includes/api/en/4x/express.md b/_includes/api/en/4x/express.md index ed0b7d77..7c17280c 100644 --- a/_includes/api/en/4x/express.md +++ b/_includes/api/en/4x/express.md @@ -1,4 +1,4 @@ -

express()

+

express()

Creates an Express application. The `express()` function is a top-level function exported by the `express` module. diff --git a/_includes/api/en/4x/req.md b/_includes/api/en/4x/req.md index e5dcd46b..85fa0003 100644 --- a/_includes/api/en/4x/req.md +++ b/_includes/api/en/4x/req.md @@ -1,4 +1,4 @@ -

Request

+

Request

The `req` object represents the HTTP request and has properties for the request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention, @@ -29,10 +29,10 @@ and supports all [built-in fields and methods](https://nodejs.org/api/http.html#
In Express 4, `req.files` is no longer available on the `req` object by default. To access uploaded files on the `req.files` object, use multipart-handling middleware like [busboy](https://www.npmjs. -com/package/busboy), [multer](https://www.npmjs.com/package/multer), -[formidable](https://www.npmjs.com/package/formidable), -[multiparty](https://www.npmjs.com/package/multiparty), -[connect-multiparty](https://www.npmjs.com/package/connect-multiparty), +com/package/busboy), [multer](https://www.npmjs.com/package/multer), +[formidable](https://www.npmjs.com/package/formidable), +[multiparty](https://www.npmjs.com/package/multiparty), +[connect-multiparty](https://www.npmjs.com/package/connect-multiparty), or [pez](https://www.npmjs.com/package/pez).
diff --git a/_includes/api/en/4x/res.md b/_includes/api/en/4x/res.md index a75e670c..a04b3606 100644 --- a/_includes/api/en/4x/res.md +++ b/_includes/api/en/4x/res.md @@ -1,4 +1,4 @@ -

Response

+

Response

The `res` object represents the HTTP response that an Express app sends when it gets an HTTP request. diff --git a/_includes/api/en/4x/router.md b/_includes/api/en/4x/router.md index 45336568..464833d1 100644 --- a/_includes/api/en/4x/router.md +++ b/_includes/api/en/4x/router.md @@ -1,4 +1,4 @@ -

Router

+

Router

A `router` object is an isolated instance of middleware and routes. You can think of it diff --git a/css/style.css b/css/style.css index e5b440dc..7f8ab28d 100644 --- a/css/style.css +++ b/css/style.css @@ -185,9 +185,9 @@ a { padding-top: 40px; } -#api-doc *:target{ - margin-top: -80px; - padding-top: 80px; +#api-doc *:target, #page-doc *:target { + margin-top: -60px; + padding-top: 60px; z-index: -1; } @@ -739,21 +739,10 @@ footer { color: #259dff; } - -/* hash link scroll buffer */ -h2 a:before { - display: block; - content: ' '; - margin-top: -40px; - height: 40px; - visibility: hidden; -} - h2 a { color: #353535 !important; } - /* responsive */ @media all and (max-width: 899px) { diff --git a/en/3x/api.md b/en/3x/api.md index 41f88db2..7421a648 100644 --- a/en/3x/api.md +++ b/en/3x/api.md @@ -15,19 +15,10 @@ redirect_from: "/3x/api.html"

3.x API

- {% include api/{{ page.lang }}/3x/express.md %} - - {% include api/{{ page.lang }}/3x/app.md %} - - {% include api/{{ page.lang }}/3x/req.md %} - - {% include api/{{ page.lang }}/3x/res.md %} - - {% include api/{{ page.lang }}/3x/middleware.md %} diff --git a/en/4x/api.md b/en/4x/api.md index 1df48894..542148ec 100644 --- a/en/4x/api.md +++ b/en/4x/api.md @@ -9,19 +9,10 @@ redirect_from: "/4x/api.html"

4.x API

- {% include api/{{ page.lang }}/4x/express.md %} - - {% include api/{{ page.lang }}/4x/app.md %} - - {% include api/{{ page.lang }}/4x/req.md %} - - {% include api/{{ page.lang }}/4x/res.md %} - - {% include api/{{ page.lang }}/4x/router.md %} diff --git a/en/advanced/best-practice-performance.md b/en/advanced/best-practice-performance.md index 0f15ca5c..68477b05 100644 --- a/en/advanced/best-practice-performance.md +++ b/en/advanced/best-practice-performance.md @@ -5,7 +5,7 @@ menu: advanced lang: en redirect_from: "/advanced/best-practice-performance.html" --- - +
# Production best practices: performance and reliability ## Overview @@ -14,12 +14,10 @@ This article discusses performance and reliability best practices for Express ap This topic clearly falls into the "devops" world, spanning both traditional development and operations. Accordingly, the information is divided into two parts: -* [Things to do in your code](#code) (the dev part). -* [Things to do in your environment / setup](#env) (the ops part). +* [Things to do in your code](#in-code) (the dev part). +* [Things to do in your environment / setup](#in-environment) (the ops part). - - -## Things to do in your code +## Things to do in your code {#in-code} Here are some things you can do in your code to improve your application's performance: @@ -49,7 +47,6 @@ Although Node and many modules provide synchronous and asynchronous versions of If you are using Node.js 4.0+ or io.js 2.1.0+, you can use the `--trace-sync-io` command-line flag to print a warning and a stack trace whenever your application uses a synchronous API. Of course, you wouldn't want to actually use this in production, but rather to ensure that your code is ready for production. See the [Weekly update for io.js 2.1.0](https://nodejs.org/en/blog/weekly-updates/weekly-update.2015-05-22/#2-1-0) for more information. - ### Do logging correctly In general, there are two reasons for logging from your app: For debugging and for logging app activity (essentially, everything else). Using `console.log()` or `console.err()` to print log messages to the terminal is common practice in development. But [these functions are synchronous](https://nodejs.org/api/console.html#console_console_1) when the destination is a terminal or a file, so they are not suitable for production, unless you pipe the output to another program. @@ -62,16 +59,14 @@ If you're logging for purposes of debugging, then instead of using `console.log( If you're logging app activity (for example, tracking traffic or API calls), instead of using `console.log()`, use a logging library like [Winston](https://www.npmjs.com/package/winston) or [Bunyan](https://www.npmjs.com/package/bunyan). For a detailed comparison of these two libraries, see the StrongLoop blog post [Comparing Winston and Bunyan Node.js Logging](https://strongloop.com/strongblog/compare-node-js-logging-winston-bunyan/). - - ### Handle exceptions properly -Node apps crash when they encounter an uncaught exception. Not handling exceptions and taking appropriate actions will make your Express app crash and go offline. If you follow the advice in [Ensure your app automatically restarts](#restart) below, then your app will recover from a crash. Fortunately, Express apps typically have a short startup time. Nevertheless, you want to avoid crashing in the first place, and to do that, you need to handle exceptions properly. +Node apps crash when they encounter an uncaught exception. Not handling exceptions and taking appropriate actions will make your Express app crash and go offline. If you follow the advice in [Ensure your app automatically restarts](#ensure-restart) below, then your app will recover from a crash. Fortunately, Express apps typically have a short startup time. Nevertheless, you want to avoid crashing in the first place, and to do that, you need to handle exceptions properly. To ensure you handle all exceptions, use the following techniques: -* [Use try-catch](#try-catch) -* [Use promises](#promises) +* [Use try-catch](#use-try-catch) +* [Use promises](#use-promises) Before diving into these topics, you should have a basic understanding of Node/Express error handling: using error-first callbacks, and propagating errors in middleware. Node uses an "error-first callback" convention for returning errors from asynchronous functions, where the first parameter to the callback function is the error object, followed by result data in succeeding parameters. To indicate no error, pass null as the first parameter. The callback function must correspondingly follow the error-first callback convention to meaningfully handle the error. And in Express, the best practice is to use the next() function to propagate errors through the middleware chain. @@ -88,8 +83,6 @@ Additionally, using `uncaughtException` is officially recognized as [crude](http We also don't recommend using [domains](https://nodejs.org/api/domain.html). It generally doesn't solve the problem and is a deprecated module. - - #### Use try-catch Try-catch is a JavaScript language construct that you can use to catch exceptions in synchronous code. Use try-catch, for example, to handle JSON parsing errors as shown below. @@ -116,8 +109,6 @@ app.get('/search', function (req, res) { However, try-catch works only for synchronous code. Because the Node platform is primarily asynchronous (particularly in a production environment), try-catch won't catch a lot of exceptions. - - #### Use promises Promises will handle any exceptions (both explicit and implicit) in asynchronous code blocks that use `then()`. Just add `.catch(next)` to the end of promise chains. For example: @@ -161,9 +152,7 @@ For more information about error-handling by using promises, see: * [Asynchronous Error Handling in Express with Promises, Generators and ES7](https://strongloop.com/strongblog/async-error-handling-expressjs-es7-promises-generators/) * [Promises in Node.js with Q – An Alternative to Callbacks](https://strongloop.com/strongblog/promises-in-node-js-with-q-an-alternative-to-callbacks/) - - -## Things to do in your environment / setup +## Things to do in your environment / setup {#in-environment} Here are some things you can do in your system environment to improve your app's performance: @@ -210,16 +199,14 @@ For more information, see [Using Environment Variables In systemd Units](https:/ If you are using StrongLoop Process Manager, you can also [set the environment variable when you install StrongLoop PM as a service](https://docs.strongloop.com/display/SLC/Setting+up+a+production+host#Settingupaproductionhost-Setenvironmentvariables). - - -### Ensure your app automatically restarts +### Ensure your app automatically restarts {#ensure-restart} In production, you don't want your application to be offline, ever. This means you need to make sure it restarts both if the app crashes and if the server itself crashes. Although you hope that neither of those events occurs, realistically you must account for both eventualities by: * Using a process manager to restart the app (and Node) when it crashes. * Using the init system provided by your OS to restart the process manager when the OS crashes. It's also possible to use the init system without a process manager. -Node applications crash if they encounter an uncaught exception. The foremost thing you need to do is to ensure your app is well-tested and handles all exceptions (see [handle exceptions properly](#exceptions) for details). But as a fail-safe, put a mechanism in place to ensure that if and when your app crashes, it will automatically restart. +Node applications crash if they encounter an uncaught exception. The foremost thing you need to do is to ensure your app is well-tested and handles all exceptions (see [handle exceptions properly](#handle-exceptions-properly) for details). But as a fail-safe, put a mechanism in place to ensure that if and when your app crashes, it will automatically restart. #### Use a process manager @@ -436,3 +423,4 @@ With load balancing, you might have to ensure that requests that are associated A reverse proxy sits in front of a web app and performs supporting operations on the requests, apart from directing requests to the app. It can handle error pages, compression, caching, serving files, and load balancing among other things. Handing over tasks that do not require knowledge of application state to a reverse proxy frees up Express to perform specialized application tasks. For this reason, it is recommended to run Express behind a reverse proxy like [Nginx](https://www.nginx.com/) or [HAProxy](http://www.haproxy.org/) in production. +
diff --git a/en/advanced/best-practice-security.md b/en/advanced/best-practice-security.md index 5ecca816..a990df7e 100644 --- a/en/advanced/best-practice-security.md +++ b/en/advanced/best-practice-security.md @@ -5,7 +5,7 @@ menu: advanced lang: en redirect_from: "/advanced/best-practice-security.html" --- - +
# Production Best Practices: Security ## Overview @@ -179,3 +179,4 @@ Here are some further recommendations from the excellent [Node.js Security Check Keep an eye out for [Node Security Project](https://nodesecurity.io/advisories) advisories that may affect Express or other modules that your app uses. In general, the Node Security Project is an excellent resource for knowledge and tools about Node security. Finally, Express apps - like any other web apps - can be vulnerable to a variety of web-based attacks. Familiarize yourself with known [web vulnerabilities](https://www.owasp.org/index.php/Top_10_2013-Top_10) and take precautions to avoid them. +
diff --git a/en/advanced/developing-template-engines.md b/en/advanced/developing-template-engines.md index c842f2b0..8f20283a 100755 --- a/en/advanced/developing-template-engines.md +++ b/en/advanced/developing-template-engines.md @@ -5,7 +5,7 @@ menu: advanced lang: en redirect_from: "/advanced/developing-template-engines.html" --- - +
# Developing template engines for Express Use the `app.engine(ext, callback)` method to create your own template engine. `ext` refers to the file extension, and `callback` is the template engine function, which accepts the following items as parameters: the location of the file, the options object, and the callback function. @@ -41,3 +41,4 @@ app.get('/', function (req, res) { }); ``` When you make a request to the home page, `index.ntl` will be rendered as HTML. +
diff --git a/en/advanced/pm.md b/en/advanced/pm.md index 22479bed..f573c02f 100755 --- a/en/advanced/pm.md +++ b/en/advanced/pm.md @@ -5,7 +5,7 @@ menu: advanced lang: en redirect_from: "/advanced/pm.html" --- - +
# Process managers for Express apps When you run Express apps for production, it is helpful to use a _process manager_ to achieve the following tasks: @@ -237,3 +237,4 @@ $ forever stopall ``` Forever has many more options, and it also provides a programmatic API. +
diff --git a/en/advanced/security-updates.md b/en/advanced/security-updates.md index da25d781..eb6698cd 100755 --- a/en/advanced/security-updates.md +++ b/en/advanced/security-updates.md @@ -5,6 +5,7 @@ menu: advanced lang: en redirect_from: "/advanced/security-updates.html" --- +
# Security updates @@ -52,3 +53,4 @@ The list below enumerates the Express vulnerabilities that were fixed in the spe * Extremely nested query string objects could cause the process to block and make the server unresponsive temporarily. * 3.3.0 * The 404 response of an unsupported method override attempt was susceptible to cross-site scripting attacks. +
diff --git a/en/changelog/4x.md b/en/changelog/4x.md index a94ec97f..b272ad38 100644 --- a/en/changelog/4x.md +++ b/en/changelog/4x.md @@ -4,7 +4,7 @@ title: Express 4.x changelog menu: changelog lang: en --- - +
# Release Change Log ## 4.14.0 - Release date: 2016-06-16 @@ -64,3 +64,4 @@ The 4.14.0 minor release includes bug fixes, security update, performance improv For a complete list of changes in this release, see [History.md](https://github.com/expressjs/express/blob/master/History.md#4134--2016-06-16). +
diff --git a/en/guide/behind-proxies.md b/en/guide/behind-proxies.md index 7f008097..6f2b1605 100755 --- a/en/guide/behind-proxies.md +++ b/en/guide/behind-proxies.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/behind-proxies.html" --- - +
# Express behind proxies When running an Express app behind a proxy, set (by using [app.set()](/{{ page.lang }}/4x/api.html#app.set)) the application variable `trust proxy` to one of the values listed in the following table. @@ -80,3 +80,4 @@ Setting a non-`false` `trust proxy` value results in three important changes: The `trust proxy` setting is implemented using the [proxy-addr](https://www.npmjs.com/package/proxy-addr) package. For more information, see its documentation. +
diff --git a/en/guide/database-integration.md b/en/guide/database-integration.md index 2a4e6473..2ac81b43 100644 --- a/en/guide/database-integration.md +++ b/en/guide/database-integration.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/database-integration.html" --- - +
# Database integration Adding the capability to connect databases to Express apps is just a matter of loading an appropriate Node.js driver for the database in your app. This document briefly explains how to add and use some of the most popular Node.js modules for database systems in your Express app: @@ -367,3 +367,4 @@ client.search({ console.trace(error.message); }); ``` +
diff --git a/en/guide/debugging.md b/en/guide/debugging.md index 7a8f4bd8..7b1630ed 100755 --- a/en/guide/debugging.md +++ b/en/guide/debugging.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/debugging.html" --- - +
# Debugging Express Express uses the [debug](https://www.npmjs.com/package/debug) module @@ -115,3 +115,4 @@ $ DEBUG=http,mail,express:* node index.js ``` For more information about `debug`, see the [debug](https://www.npmjs.com/package/debug). +
diff --git a/en/guide/error-handling.md b/en/guide/error-handling.md index 950404bf..d17e0b86 100755 --- a/en/guide/error-handling.md +++ b/en/guide/error-handling.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/error-handling.html" --- - +
# Error handling Define error-handling middleware functions in the same way as other middleware functions, @@ -68,7 +68,7 @@ function logErrors(err, req, res, next) { Also in this example, `clientErrorHandler` is defined as follows; in this case, the error is explicitly passed along to the next one. -Notice that when _not_ calling "next" in an error-handling function, you are responsible for writing (and ending) the response. Otherwise those requests will "hang" and will not be eligible for garbage collection. +Notice that when _not_ calling "next" in an error-handling function, you are responsible for writing (and ending) the response. Otherwise those requests will "hang" and will not be eligible for garbage collection. ```js function clientErrorHandler(err, req, res, next) { @@ -146,5 +146,6 @@ function errorHandler(err, req, res, next) { } ``` -Note that the default error handler can get triggered if you call `next()` with an error +Note that the default error handler can get triggered if you call `next()` with an error in your code more than once, even if custom error handling middleware is in place. +
diff --git a/en/guide/migrating-4.md b/en/guide/migrating-4.md index ff37f716..477db9ba 100755 --- a/en/guide/migrating-4.md +++ b/en/guide/migrating-4.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/migrating-4.html" --- - +
# Moving to Express 4

Overview

@@ -602,3 +602,4 @@ You have now moved the functionality of `./bin/www` back to `app.js`. This change is not recommended, but the exercise helps you to understand how the `./bin/www` file works, and why the `app.js` file no longer starts on its own. +
diff --git a/en/guide/migrating-5.md b/en/guide/migrating-5.md index a1d1eee1..148072bf 100755 --- a/en/guide/migrating-5.md +++ b/en/guide/migrating-5.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/migrating-5.html" --- - +
# Moving to Express 5

Overview

@@ -64,7 +64,7 @@ If you use any of these methods or properties in your app, it will crash. So, yo Express 5 no longer supports the `app.del()` function. If you use this function an error is thrown. For registering HTTP DELETE routes, use the `app.delete()` function instead. -Initially `del` was used instead of `delete`, because `delete` is a reserved keyword in JavaScript. However, as of ECMAScript 6, `delete` and other reserved keywords can legally be used as property names. +Initially `del` was used instead of `delete`, because `delete` is a reserved keyword in JavaScript. However, as of ECMAScript 6, `delete` and other reserved keywords can legally be used as property names.

app.param(fn)

@@ -130,3 +130,4 @@ In Express 4.7 and Express 5 onwards, the query parser option can accept `false`

res.render()

This method now enforces asynchronous behavior for all view engines, avoiding bugs caused by view engines that had a synchronous implementation and that violated the recommended interface. +
diff --git a/en/guide/routing.md b/en/guide/routing.md index 45565e33..37ed2865 100755 --- a/en/guide/routing.md +++ b/en/guide/routing.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/routing.html" --- - +
# Routing _Routing_ refers to the definition of application end points (URIs) and how they respond to client requests. @@ -327,3 +327,4 @@ app.use('/birds', birds); ``` The app will now be able to handle requests to `/birds` and `/birds/about`, as well as call the `timeLog` middleware function that is specific to the route. +
diff --git a/en/guide/using-middleware.md b/en/guide/using-middleware.md index 10bf7c8a..30662c2a 100644 --- a/en/guide/using-middleware.md +++ b/en/guide/using-middleware.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/using-middleware.html" --- - +
# Using middleware Express is a routing and middleware web framework that has minimal functionality of its own: An Express application is essentially a series of middleware function calls. @@ -253,3 +253,4 @@ app.use(cookieParser()); ``` For a partial list of third-party middleware functions that are commonly used with Express, see: [Third-party middleware](../resources/middleware.html). +
diff --git a/en/guide/using-template-engines.md b/en/guide/using-template-engines.md index a6b12e09..fde42bcc 100755 --- a/en/guide/using-template-engines.md +++ b/en/guide/using-template-engines.md @@ -5,7 +5,7 @@ menu: guide lang: en redirect_from: "/guide/using-template-engines.html" --- - +
# Using template engines with Express A _template engine_ enables you to use static template files in your application. At runtime, the template engine replaces @@ -70,3 +70,4 @@ When you make a request to the home page, the `index.pug` file will be rendered To learn more about how template engines work in Express, see: ["Developing template engines for Express"](/{{ page.lang }}/advanced/developing-template-engines.html). +
diff --git a/en/guide/writing-middleware.md b/en/guide/writing-middleware.md index fac86b34..39cd0033 100755 --- a/en/guide/writing-middleware.md +++ b/en/guide/writing-middleware.md @@ -5,12 +5,12 @@ menu: guide lang: en redirect_from: "/guide/writing-middleware.html" --- - +
# Writing middleware for use in Express apps

Overview

-_Middleware_ functions are functions that have access to the [request object](/4x/api.html#req) (`req`), the [response object](/4x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. The next middleware function is commonly denoted by a variable named `next`. +_Middleware_ functions are functions that have access to the [request object](/{{ page.lang }}/4x/api.html#req) (`req`), the [response object](/{{ page.lang }}/4x/api.html#res) (`res`), and the next middleware function in the application's request-response cycle. The next middleware function is commonly denoted by a variable named `next`. Middleware functions can perform the following tasks: @@ -36,15 +36,15 @@ The following figure shows the elements of a middleware function call:
Callback argument to the middleware function, called "next" by convention.
-
HTTP response argument to the middleware function, called "res" by convention.
+
HTTP response argument to the middleware function, called "res" by convention.
-
HTTP request argument to the middleware function, called "req" by convention.
+
HTTP request argument to the middleware function, called "req" by convention.

Example

-Here is an example of a simple "Hello World" Express application. +Here is an example of a simple "Hello World" Express application. The remainder of this article will define and add two middleware functions to the application: one called `myLogger` that prints a simple log message and another called `requestTime` that displays the timestamp of the HTTP request. @@ -72,7 +72,7 @@ var myLogger = function (req, res, next) {
Notice the call above to `next()`. Calling this function invokes the next middleware function in the app. -The `next()` function is not a part of the Node.js or Express API, but is the third argument that is passed to the middleware function. The `next()` function could be named anything, but by convention it is always named "next". +The `next()` function is not a part of the Node.js or Express API, but is the third argument that is passed to the middleware function. The `next()` function could be named anything, but by convention it is always named "next". To avoid confusion, always use this convention.
@@ -107,8 +107,8 @@ The middleware function `myLogger` simply prints a message, then passes on the r

Middleware function requestTime

-Next, we'll create a middleware function called "requestTime" and add it as a property called `requestTime` -to the request object. +Next, we'll create a middleware function called "requestTime" and add it as a property called `requestTime` +to the request object. ```js var requestTime = function (req, res, next) { @@ -143,4 +143,5 @@ When you make a request to the root of the app, the app now displays the timesta Because you have access to the request object, the response object, the next middleware function in the stack, and the whole Node.js API, the possibilities with middleware functions are endless. -For more information about Express middleware, see: [Using Express middleware](/guide/using-middleware.html). +For more information about Express middleware, see: [Using Express middleware](/{{ page.lang }}/guide/using-middleware.html). +
diff --git a/en/resources/books-blogs.md b/en/resources/books-blogs.md index f5ad0a9a..5049d13c 100644 --- a/en/resources/books-blogs.md +++ b/en/resources/books-blogs.md @@ -5,7 +5,7 @@ menu: resources lang: en redirect_from: "/resources/books-blogs.html" --- - +
# Books and blogs
Disclaimer: Unendorsed community content.
@@ -49,3 +49,4 @@ texxtoor, September 2015. In deutscher Sprache / in German language ### Add your blog here! [Edit the Markdown file](https://github.com/strongloop/expressjs.com/blob/gh-pages/{{ page.lang }}/resources/books-blogs.md) and add a link to your blog, then submit a pull request (GitHub login required). Follow the format of the above listings. +
diff --git a/en/resources/community.md b/en/resources/community.md index 7a8e677c..f3dac083 100755 --- a/en/resources/community.md +++ b/en/resources/community.md @@ -5,7 +5,7 @@ menu: resources lang: en redirect_from: "/resources/community.html" --- - +
# Community ## Mailing List @@ -15,7 +15,7 @@ discussions in the [Google Group](https://groups.google.com/group/express-js). ## Gitter -The [strongloop/express chatroom](https://gitter.im/strongloop/express) is great place +The [expressjs/express chatroom](https://gitter.im/expressjs/express) is great place for developers interested in the everyday discussions related to Express. ## IRC channel @@ -27,28 +27,29 @@ feedback. ## Issues If you've come across what you think is a bug, or just want to make -a feature request open a ticket in the [issue queue](https://github.com/strongloop/express/issues). +a feature request open a ticket in the [issue queue](https://github.com/expressjs/express/issues). ## Technical committee The Express technical committee meets online every two weeks to discuss development and maintenance of Express, and other issues relevant to the Express project. -Each meeting is typically announced in an [expressjs/discussions issue](https://github.com/expressjs/discussions/issues) with a link to the Google Hangout, which is -open to all observers. +Each meeting is typically announced in an [expressjs/discussions issue](https://github.com/expressjs/discussions/issues) with a link to the Google Hangout, which is +open to all observers. ## Examples -View dozens of Express application [examples](https://github.com/strongloop/express/tree/master/examples) +View dozens of Express application [examples](https://github.com/expressjs/express/tree/master/examples) in the repository covering everything from API design and authentication to template engine integration. ## Other modules Our vibrant community has created a large variety of extensions, -[middleware modules](/{{ page.lang }}/resources/middleware.html) and -[higher-level frameworks](frameworks.html). +[middleware modules](/{{ page.lang }}/resources/middleware.html) and +[higher-level frameworks](frameworks.html). Other middleware and related modules are in: - [jshttp](https://jshttp.github.io/) - [pillarjs](https://pillarjs.github.io/) -See also the [Express wiki](https://github.com/strongloop/express/wiki). +See also the [Express wiki](https://github.com/expressjs/express/wiki). +
diff --git a/en/resources/companies-using-express.md b/en/resources/companies-using-express.md index 875c886b..bc5b1a27 100644 --- a/en/resources/companies-using-express.md +++ b/en/resources/companies-using-express.md @@ -5,10 +5,9 @@ menu: resources lang: en redirect_from: "/resources/companies-using-express.html" --- - +
# Companies using Express in production -
@@ -56,3 +55,4 @@ redirect_from: "/resources/companies-using-express.html" If your company is using Express, let us know: [callback@us.ibm.com](mailto:callback@us.ibm.com). +
diff --git a/en/resources/contributing.md b/en/resources/contributing.md index 404d0de8..d4cbec2e 100644 --- a/en/resources/contributing.md +++ b/en/resources/contributing.md @@ -5,11 +5,11 @@ menu: resources lang: en redirect_from: "/resources/community.html" --- - +
# Contributing to Express -Express and the other projects in the [expressjs organization on GitHub](https://github.com/expressjs) are projects of the [Node.js Foundation](https://nodejs.org/foundation/). -These projects are governed under the general policies and guidelines of the Node.js Foundation along with the additional guidelines below. +Express and the other projects in the [expressjs organization on GitHub](https://github.com/expressjs) are projects of the [Node.js Foundation](https://nodejs.org/foundation/). +These projects are governed under the general policies and guidelines of the Node.js Foundation along with the additional guidelines below. * [Technical committee](#technical-committee) * [Community contributing guide](#community-contributing-guide) @@ -19,11 +19,11 @@ These projects are governed under the general policies and guidelines of the Nod ## Technical committee The Express technical committee meets online every two weeks to discuss development and maintenance of Express, and other issues relevant to the Express project. -Each meeting is typically announced in an [expressjs/discussions issue](https://github.com/expressjs/discussions/issues) with a link to the Google Hangout, which is open to all observers. +Each meeting is typically announced in an [expressjs/discussions issue](https://github.com/expressjs/discussions/issues) with a link to the Google Hangout, which is open to all observers. Members of the Express technical committee are: -- [@blakeembrey](https://github.com/blakeembrey) - Blake Embrey +- [@blakeembrey](https://github.com/blakeembrey) - Blake Embrey - [@crandmck](https://github.com/crandmck) - Rand McKinney - [@dougwilson](https://github.com/dougwilson) - Douglas Wilson - [@Fishrock123](https://github.com/Fishrock123) - Jeremiah Senkpiel @@ -52,19 +52,19 @@ Vocabulary: * A **Contributor** is any individual creating or commenting on an issue or pull request. * A **Committer** is a subset of contributors who have been given write access to the repository. -* A **TC (Technical Committee)** is a group of committers representing the required technical +* A **TC (Technical Committee)** is a group of committers representing the required technical expertise to resolve rare disputes. ### Logging issues -Log an issue for any question or problem you might have. When in doubt, log an issue, +Log an issue for any question or problem you might have. When in doubt, log an issue, any additional policies about what to include will be provided in the responses. The only exception is security dislosures which should be sent privately. Committers may direct you to another repository, ask for additional clarifications, and add appropriate metadata before the issue is addressed. -Please be courteous, respectful, and every participant is expected to follow the +Please be courteous, respectful, and every participant is expected to follow the project's Code of Conduct. ### Contributions @@ -76,24 +76,24 @@ pull requests. No pull request can be merged without being reviewed. For non-trivial contributions, pull requests should sit for at least 36 hours to ensure that -contributors in other timezones have time to review. Consideration should also be given to -weekends and other holiday periods to ensure active committers all have reasonable time to +contributors in other timezones have time to review. Consideration should also be given to +weekends and other holiday periods to ensure active committers all have reasonable time to become involved in the discussion and review process if they wish. The default for each contribution is that it is accepted once no committer has an objection. -During review committers may also request that a specific contributor who is most versed in a -particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" -process for contributions to land. Once all issues brought by committers are addressed it can +During review committers may also request that a specific contributor who is most versed in a +particular area gives a "LGTM" before the PR can be merged. There is no additional "sign off" +process for contributions to land. Once all issues brought by committers are addressed it can be landed by any committer. -In the case of an objection being raised in a pull request by another committer, all involved -committers should seek to arrive at a consensus by way of addressing concerns being expressed +In the case of an objection being raised in a pull request by another committer, all involved +committers should seek to arrive at a consensus by way of addressing concerns being expressed by discussion, compromise on the proposed change, or withdrawal of the proposed change. If a contribution is controversial and committers cannot agree about how to get it to land or if it should land then it should be escalated to the TC. TC members should regularly -discuss pending contributions in order to find a resolution. It is expected that only a -small minority of issues be brought to the TC for resolution and that discussion and +discuss pending contributions in order to find a resolution. It is expected that only a +small minority of issues be brought to the TC for resolution and that discussion and compromise among committers be the default resolution mechanism. ### Becoming a committer @@ -106,20 +106,20 @@ proper review, and have other committers merge their pull requests. ### TC process -The TC uses a "consensus seeking" process for issues that are escalated to the TC. +The TC uses a "consensus seeking" process for issues that are escalated to the TC. The group tries to find a resolution that has no open objections among TC members. If a consensus cannot be reached that has no objections then a majority wins vote -is called. It is also expected that the majority of decisions made by the TC are via +is called. It is also expected that the majority of decisions made by the TC are via a consensus seeking process and that voting is only used as a last-resort. -Resolution may involve returning the issue to committers with suggestions on how to -move forward towards a consensus. It is not expected that a meeting of the TC +Resolution may involve returning the issue to committers with suggestions on how to +move forward towards a consensus. It is not expected that a meeting of the TC will resolve all issues on its agenda during that meeting and may prefer to continue the discussion happening among the committers. Members can be added to the TC at any time. Any committer can nominate another committer to the TC and the TC uses its standard consensus seeking process to evaluate whether or -not to add this new member. Members who do not participate consistently at the level of +not to add this new member. Members who do not participate consistently at the level of a majority of the other members are expected to resign. ## Collaborator's guide @@ -139,7 +139,7 @@ Open issues for the expressjs.com website in https://github.com/expressjs/expres ### Branches * Use the `master` branch for bug fixes or minor work that is intended for the current release stream -* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express +* Use the correspondingly named branch, e.g. `5.0`, for anything intended for a future release of Express ### Steps for contributing @@ -207,3 +207,4 @@ involving the following steps: If you have suggestions on how this process could be improved please submit a pull request. +
diff --git a/en/resources/frameworks.md b/en/resources/frameworks.md index 7b1d96cd..79a2b02a 100644 --- a/en/resources/frameworks.md +++ b/en/resources/frameworks.md @@ -4,7 +4,7 @@ title: Frameworks built on Express menu: frameworks lang: en --- - +
# Frameworks built on Express Several popular Node.js frameworks are built on Express: @@ -17,4 +17,4 @@ Several popular Node.js frameworks are built on Express: - **[LoopBack](http://loopback.io)**: Highly-extensible, open-source Node.js framework for quickly creating dynamic end-to-end REST APIs. - **[MEAN](http://mean.io/)**: Opinionated fullstack JavaScript framework that simplifies and accelerates web application development. - **[Sails](http://sailsjs.org/)**: MVC framework for Node.js for building practical, production-ready apps. - +
diff --git a/en/resources/glossary.md b/en/resources/glossary.md index b7094692..9cfbdbbe 100755 --- a/en/resources/glossary.md +++ b/en/resources/glossary.md @@ -5,7 +5,7 @@ menu: resources lang: en redirect_from: "/resources/glossary.html" --- - +
# Glossary ### application @@ -55,3 +55,4 @@ Part of a URL that identifies a resource. For example, in `http://foo.com/produ ### router See [router](/{{ page.lang }}/api.html#router) in the API reference. +
diff --git a/en/resources/middleware.md b/en/resources/middleware.md index 4694e29a..5ec111a1 100755 --- a/en/resources/middleware.md +++ b/en/resources/middleware.md @@ -5,7 +5,7 @@ menu: resources lang: en redirect_from: "/resources/middleware.html" --- - +
## Express middleware The Express middleware modules listed here are maintained by the @@ -66,3 +66,4 @@ These are some additional popular middleware modules. | [sriracha-admin](https://github.com/hdngr/siracha) | Dynamically generate an admin site for Mongoose. | For more middleware modules, see [http-framework](https://github.com/Raynos/http-framework/wiki/Modules). +
diff --git a/en/resources/middleware/body-parser.md b/en/resources/middleware/body-parser.md index 10182c5d..b03542ef 100644 --- a/en/resources/middleware/body-parser.md +++ b/en/resources/middleware/body-parser.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/body-parser.html' name: body-parser --- - +
# body-parser [![NPM Version][npm-image]][npm-url] @@ -416,3 +416,4 @@ app.use(bodyParser.text({ type: 'text/html' })) [downloads-url]: https://npmjs.org/package/body-parser [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/compression.md b/en/resources/middleware/compression.md index 0683584c..46d92941 100644 --- a/en/resources/middleware/compression.md +++ b/en/resources/middleware/compression.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/compression.html' name: compression --- - +
# compression [![NPM Version][npm-image]][npm-url] @@ -240,3 +240,4 @@ app.get('/events', function (req, res) { [downloads-url]: https://npmjs.org/package/compression [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/connect-rid.md b/en/resources/middleware/connect-rid.md index a5a9f66a..4fb5a61a 100644 --- a/en/resources/middleware/connect-rid.md +++ b/en/resources/middleware/connect-rid.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/connect-rid.html' name: connect-rid --- - +
connect-rid ======= @@ -58,3 +58,4 @@ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +
diff --git a/en/resources/middleware/cookie-parser.md b/en/resources/middleware/cookie-parser.md index 917f4fbe..96574e93 100644 --- a/en/resources/middleware/cookie-parser.md +++ b/en/resources/middleware/cookie-parser.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/cookie-parser.html' name: cookie-parser --- - +
# cookie-parser [![NPM Version][npm-image]][npm-url] @@ -92,3 +92,4 @@ app.listen(8080) [coveralls-url]: https://coveralls.io/r/expressjs/cookie-parser?branch=master [downloads-image]: https://img.shields.io/npm/dm/cookie-parser.svg [downloads-url]: https://npmjs.org/package/cookie-parser +
diff --git a/en/resources/middleware/cookie-session.md b/en/resources/middleware/cookie-session.md index 54e1a9f5..3ba133dd 100644 --- a/en/resources/middleware/cookie-session.md +++ b/en/resources/middleware/cookie-session.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/cookie-session.html' name: cookie-session --- - +
# cookie-session [![NPM Version][npm-image]][npm-url] @@ -198,3 +198,4 @@ move to an [alternative session strategy](https://github.com/expressjs/session#c [downloads-url]: https://npmjs.org/package/cookie-session [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/cors.md b/en/resources/middleware/cors.md index 633f016e..2bde6462 100644 --- a/en/resources/middleware/cors.md +++ b/en/resources/middleware/cors.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/cors.html' name: cors --- - +
# `cors` CORS is a node.js package for providing a [Connect](http://www.senchalabs.org/connect/)/[Express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. @@ -174,7 +174,7 @@ app.listen(80, function(){ ## Configuration Options * `origin`: Configures the **Access-Control-Allow-Origin** CORS header. Possible values: - - `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`, or set it to `false` to disable CORS. + - `Boolean` - set `origin` to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`, or set it to `false` to disable CORS. - `String` - set `origin` to a specific origin. For example if you set it to `"http://example.com"` only requests from "http://example.com" will be allowed. - `RegExp` - set `origin` to a regular expression pattern which will be used to test the request origin. If it's a match, the request origin will be reflected. For example the pattern `/example\.com$/` will reflect any request that is coming from an origin ending with "example.com". - `Array` - set `origin` to an array of valid origins. Each origin can be a `String` or a `RegExp`. For example `["http://example1.com", /\.example2\.com$/]` will accept any request from "http://example1.com" or from a subdomain of "example2.com". @@ -214,3 +214,4 @@ Code for that demo can be found here: ## Author [Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com)) +
diff --git a/en/resources/middleware/csurf.md b/en/resources/middleware/csurf.md index 4a85a1eb..fad10e7a 100644 --- a/en/resources/middleware/csurf.md +++ b/en/resources/middleware/csurf.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/csurf.html' name: csurf --- - +
# csurf [![NPM Version][npm-image]][npm-url] @@ -147,7 +147,7 @@ input field named `_csrf`: ```html
- + Favorite color:
@@ -194,3 +194,4 @@ app.use(function (err, req, res, next) { [downloads-url]: https://npmjs.org/package/csurf [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/errorhandler.md b/en/resources/middleware/errorhandler.md index f03100b9..faa4d95e 100644 --- a/en/resources/middleware/errorhandler.md +++ b/en/resources/middleware/errorhandler.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/errorhandler.html' name: errorhandler --- - +
# errorhandler [![NPM Version][npm-image]][npm-url] @@ -131,3 +131,4 @@ function errorNotification(err, str, req) { [downloads-url]: https://npmjs.org/package/errorhandler [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/method-override.md b/en/resources/middleware/method-override.md index 5981918f..f4e2a605 100644 --- a/en/resources/middleware/method-override.md +++ b/en/resources/middleware/method-override.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/method-override.html' name: method-override --- - +
# method-override [![NPM Version][npm-image]][npm-url] @@ -180,3 +180,4 @@ Example call with query override using HTML `
`: [downloads-url]: https://npmjs.org/package/method-override [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/morgan.md b/en/resources/middleware/morgan.md index 487ea42f..3b30ba99 100644 --- a/en/resources/middleware/morgan.md +++ b/en/resources/middleware/morgan.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/morgan.html' name: morgan --- - +
# morgan [![NPM Version][npm-image]][npm-url] @@ -331,3 +331,4 @@ function assignId(req, res, next) { [downloads-url]: https://npmjs.org/package/morgan [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/multer.md b/en/resources/middleware/multer.md index ff217e14..9eb64928 100644 --- a/en/resources/middleware/multer.md +++ b/en/resources/middleware/multer.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/multer.html' name: multer --- - +
# Multer [![Build Status](https://travis-ci.org/expressjs/multer.svg?branch=master)](https://travis-ci.org/expressjs/multer) [![NPM version](https://badge.fury.io/js/multer.svg)](https://badge.fury.io/js/multer) [![js-standard-style](https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat)](https://github.com/feross/standard) Multer is a node.js middleware for handling `multipart/form-data`, which is primarily used for uploading files. It is written @@ -288,3 +288,4 @@ storage engine. ## License [MIT](LICENSE) +
diff --git a/en/resources/middleware/response-time.md b/en/resources/middleware/response-time.md index 8f3dd266..1324f120 100644 --- a/en/resources/middleware/response-time.md +++ b/en/resources/middleware/response-time.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/response-time.html' name: response-time --- - +
# response-time [![NPM Version][npm-image]][npm-url] @@ -144,3 +144,4 @@ app.get('/', function (req, res) { [downloads-url]: https://npmjs.org/package/response-time [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/serve-favicon.md b/en/resources/middleware/serve-favicon.md index 421c26bb..437a007c 100644 --- a/en/resources/middleware/serve-favicon.md +++ b/en/resources/middleware/serve-favicon.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/serve-favicon.html' name: serve-favicon --- - +
# serve-favicon [![NPM Version][npm-image]][npm-url] @@ -139,3 +139,4 @@ server.listen(3000); [downloads-url]: https://npmjs.org/package/serve-favicon [gittip-image]: https://img.shields.io/gittip/dougwilson.svg [gittip-url]: https://www.gittip.com/dougwilson/ +
diff --git a/en/resources/middleware/serve-index.md b/en/resources/middleware/serve-index.md index f45e3d9c..41641c1b 100644 --- a/en/resources/middleware/serve-index.md +++ b/en/resources/middleware/serve-index.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/serve-index.html' name: serve-index --- - +
# serve-index [![NPM Version][npm-image]][npm-url] @@ -153,3 +153,4 @@ are created by/copyright of [FAMFAMFAM](http://www.famfamfam.com/). [downloads-url]: https://npmjs.org/package/serve-index [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/serve-static.md b/en/resources/middleware/serve-static.md index eeebada3..c2f0d8b4 100644 --- a/en/resources/middleware/serve-static.md +++ b/en/resources/middleware/serve-static.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/serve-static.html' name: serve-static --- - +
# serve-static [![NPM Version][npm-image]][npm-url] @@ -252,3 +252,4 @@ function setCustomCacheControl (res, path) { [downloads-url]: https://npmjs.org/package/serve-static [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/session.md b/en/resources/middleware/session.md index d2b8896f..0a784dcb 100644 --- a/en/resources/middleware/session.md +++ b/en/resources/middleware/session.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/session.html' name: session --- - +
# express-session [![NPM Version][npm-image]][npm-url] @@ -662,3 +662,4 @@ app.get('/bar', function (req, res, next) { [downloads-url]: https://npmjs.org/package/express-session [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/timeout.md b/en/resources/middleware/timeout.md index 1bcded13..8197e7c7 100644 --- a/en/resources/middleware/timeout.md +++ b/en/resources/middleware/timeout.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/timeout.html' name: timeout --- - +
# connect-timeout [![NPM Version][npm-image]][npm-url] @@ -169,3 +169,4 @@ app.listen(3000); [downloads-url]: https://npmjs.org/package/connect-timeout [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://www.gratipay.com/dougwilson/ +
diff --git a/en/resources/middleware/vhost.md b/en/resources/middleware/vhost.md index 32f2ca5d..a694c54f 100644 --- a/en/resources/middleware/vhost.md +++ b/en/resources/middleware/vhost.md @@ -6,7 +6,7 @@ lang: en redirect_from: '/resources/middleware/vhost.html' name: vhost --- - +
# vhost [![NPM Version][npm-image]][npm-url] @@ -167,3 +167,4 @@ app.listen(3000) [downloads-url]: https://npmjs.org/package/vhost [gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg [gratipay-url]: https://gratipay.com/dougwilson/ +
diff --git a/en/resources/utils.md b/en/resources/utils.md index 2f2b9bea..ebf502f3 100644 --- a/en/resources/utils.md +++ b/en/resources/utils.md @@ -5,7 +5,7 @@ menu: resources lang: en redirect_from: "/resources/utilities.html" --- - +
## Express utility functions The [pillarjs](https://github.com/pillarjs) GitHub organization contains a number of modules @@ -27,3 +27,4 @@ for utility functions that may be generally useful. For additional low-level HTTP-related modules, see [jshttp](http://jshttp.github.io/) . +
diff --git a/en/starter/basic-routing.md b/en/starter/basic-routing.md index da5b0e68..6d5e1704 100755 --- a/en/starter/basic-routing.md +++ b/en/starter/basic-routing.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/basic-routing.html" --- - +
# Basic routing _Routing_ refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on). @@ -64,3 +64,4 @@ app.delete('/user', function (req, res) { ``` For more details about routing, see the [routing guide](/{{ page.lang }}/guide/routing.html). +
diff --git a/en/starter/faq.md b/en/starter/faq.md index fee63b6e..ec307ecc 100755 --- a/en/starter/faq.md +++ b/en/starter/faq.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/faq.html" --- - +
# FAQ ## How should I structure my application? @@ -84,3 +84,4 @@ You don't! There's no need to "render" HTML with the `res.render()` function. If you have a specific file, use the `res.sendFile()` function. If you are serving many assets from a directory, use the `express.static()` middleware function. +
diff --git a/en/starter/generator.md b/en/starter/generator.md index fc755aa5..f2a18287 100755 --- a/en/starter/generator.md +++ b/en/starter/generator.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/generator.html" --- - +
# Express application generator Use the application generator tool, `express-generator`, to quickly create an application skeleton. @@ -107,3 +107,4 @@ The generated app has the following directory structure:
The app structure created by the generator is just one of many ways to structure Express apps. Feel free to use this structure or modify it to best suit your needs.
+
diff --git a/en/starter/hello-world.md b/en/starter/hello-world.md index bacdb6c9..223f6cdc 100755 --- a/en/starter/hello-world.md +++ b/en/starter/hello-world.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/hello-world.html" --- - +
# Hello world example
@@ -44,3 +44,4 @@ $ node app.js ``` Then, load `http://localhost:3000/` in a browser to see the output. +
diff --git a/en/starter/installing.md b/en/starter/installing.md index 3dfce0b3..c6a6a936 100755 --- a/en/starter/installing.md +++ b/en/starter/installing.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/installing.html" --- - +
# Installing Assuming you've already installed [Node.js](https://nodejs.org/), create a directory to hold your application, and make that your working directory. @@ -47,3 +47,4 @@ $ npm install express Node modules installed with the `--save` option are added to the `dependencies` list in the `package.json` file. Afterwards, running `npm install` in the `app` directory will automatically install modules in the dependencies list.
+
diff --git a/en/starter/static-files.md b/en/starter/static-files.md index 29104a89..72bc0772 100755 --- a/en/starter/static-files.md +++ b/en/starter/static-files.md @@ -5,7 +5,7 @@ menu: starter lang: en redirect_from: "/starter/static-files.html" --- - +
# Serving static files in Express To serve static files such as images, CSS files, and JavaScript files, use the `express.static` built-in middleware function in Express. @@ -60,3 +60,4 @@ However, the path that you provide to the `express.static` function is relative ```js app.use('/static', express.static(__dirname + '/public')); ``` +
diff --git a/index.md b/index.md index 8e57a037..1f4d281a 100644 --- a/index.md +++ b/index.md @@ -34,7 +34,7 @@ redirect_from: "/en/index.html"
-

Frameworks

Many
popular frameworks are based on Express. +

Frameworks

Many popular frameworks are based on Express.