Skip to content

Commit

Permalink
docs: fixed typos, spaces, and punctuation (#1482)
Browse files Browse the repository at this point in the history
* docs: added punctuation

* docs: added punctuation

* docs: added punctuation

* docs: removed spaces

* docs: reverted changes from generated files

* docs: express.js as Express
  • Loading branch information
grjan7 committed Apr 11, 2024
1 parent ef32d3d commit 8bc34dd
Show file tree
Hide file tree
Showing 46 changed files with 119 additions and 118 deletions.
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ See [LICENSE.md](LICENSE.md) for the full license.
- Russian
- Korean

Therefore we can no longer accept community translations for these languages, except for corrections
Therefore, we can no longer accept community translations for these languages, except for corrections
to the existing translations and updates to align with changes or additions to the English documentation.

To contribute a translation into another language, following the procedure below.
Expand Down
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,26 @@ To preview the website locally:

1. Install the [jekyll-redirect-from](https://github.com/jekyll/jekyll-redirect-from) gem:

```
```sh
$ gem install jekyll-redirect-from
```

1. clone this repository by running the following command:
```
1. Clone this repository by running the following command:
```sh
$ git clone https://github.com/expressjs/expressjs.com.git
```

1. navigate to the cloned repository directory and run the following command:
1. Navigate to the cloned repository directory and run the following command:

```
```sh
$ bundle install
```

Bundler will look in the Gemfile for which gems to install. The `github-pages` gem includes the same version of Jekyll and other dependencies as used by GitHub Pages, so that your local setup mirrors GitHub Pages as closely as possible.

1. Run Jekyll using the following command:

```
```sh
$ bundle exec jekyll serve
```

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/app-METHOD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Routes an HTTP request, where METHOD is the HTTP method of the request, such as GET,
PUT, POST, and so on, in lowercase. Thus, the actual methods are `app.get()`,
`app.post()`, `app.put()`, and so on. See [Routing methods](#routing-methods) below for the complete list.
`app.post()`, `app.put()`, and so on. See [Routing methods](#routing-methods) below for the complete list.

{% include api/en/5x/routing-args.html %}

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/app-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ app.all('/secret', (req, res, next) => {
})
```

The `app.all()` method is useful for mapping "global" logic for specific path prefixes or arbitrary matches. For example, if you put the following at the top of all other
The `app.all()` method is useful for mapping "global" logic for specific path prefixes or arbitrary matches. For example, if you put the following at the top of all other
route definitions, it requires that all routes from that point on
require authentication, and automatically load a user. Keep in mind
that these callbacks do not have to act as end-points: `loadUser`
Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/app-onmount.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ The `mount` event is fired on a sub-app, when it is mounted on a parent app. The

Sub-apps will:

* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Inherit the value of settings with no default value.

For details, see [Application settings](/en/5x/api.html#app.settings.table).
Expand Down
6 changes: 3 additions & 3 deletions _includes/api/en/5x/app-settings.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ The following table lists application settings.

Note that sub-apps will:

* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Inherit the value of settings with no default value; these are explicitly noted in the table below.

Exceptions: Sub-apps will inherit the value of `trust proxy` even though it has a default value (for backward-compatibility);
Expand Down Expand Up @@ -68,7 +68,7 @@ Sub-apps will not inherit the value of `view cache` in production (when `NODE_EN
</td>
<td>Boolean</td>
<td markdown="1">
Enable escaping JSON responses from the `res.json`, `res.jsonp`, and `res.send` APIs. This will escape the characters `<`, `>`, and `&` as Unicode escape sequences in JSON. The purpose of this it to assist with [mitigating certain types of persistent XSS attacks](https://blog.mozilla.org/security/2017/07/18/web-service-audits-firefox-accounts/) when clients sniff responses for HTML.
Enable escaping JSON responses from the `res.json`, `res.jsonp`, and `res.send` APIs. This will escape the characters `<`, `>`, and `&` as Unicode escape sequences in JSON. The purpose of this is to assist with [mitigating certain types of persistent XSS attacks](https://blog.mozilla.org/security/2017/07/18/web-service-audits-firefox-accounts/) when clients sniff responses for HTML.
<p><b>NOTE</b>: Sub-apps will inherit the value of this setting.</p>
</td>
<td>N/A (undefined)</td>
Expand Down Expand Up @@ -141,7 +141,7 @@ A custom query string parsing function will receive the complete query string, a
<p>
When enabled, Express attempts to determine the IP address of the client connected through the front-facing proxy, or series of proxies. The `req.ips` property, then contains an array of IP addresses the client is connected through. To enable it, use the values described in the <a href="#trust.proxy.options.table">trust proxy options table</a>.
</p><p>
The `trust proxy` setting is implemented using the <a href="https://www.npmjs.org/package/proxy-addr">proxy-addr</a> package. For more information, see its documentation.
The `trust proxy` setting is implemented using the <a href="https://www.npmjs.org/package/proxy-addr">proxy-addr</a> package. For more information, see its documentation.
</p><p>
<b>NOTE</b>: Sub-apps <i>will</i> inherit the value of this setting, even though it has a default value.
</p>
Expand Down
4 changes: 2 additions & 2 deletions _includes/api/en/5x/app-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ app.use((req, res, next) => {

Sub-apps will:

* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Not inherit the value of settings that have a default value. You must set the value in the sub-app.
* Inherit the value of settings with no default value.

For details, see [Application settings](/en/5x/api.html#app.settings.table).
Expand All @@ -49,7 +49,7 @@ app.get('/', (req, res) => {

**Error-handling middleware**

Error-handling middleware always takes _four_ arguments. You must provide four arguments to identify it as an error-handling middleware function. Even if you don't need to use the `next` object, you must specify it to maintain the signature. Otherwise, the `next` object will be interpreted as regular middleware and will fail to handle errors. For details about error-handling middleware, see: [Error handling](/{{ page.lang }}/guide/error-handling.html).
Error-handling middleware always takes _four_ arguments. You must provide four arguments to identify it as an error-handling middleware function. Even if you don't need to use the `next` object, you must specify it to maintain the signature. Otherwise, the `next` object will be interpreted as regular middleware and will fail to handle errors. For details about error-handling middleware, see: [Error handling](/{{ page.lang }}/guide/error-handling.html).

Define error-handling middleware functions in the same way as other middleware functions, except with four arguments instead of three, specifically with the signature `(err, req, res, next)`):

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/req-baseUrl.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,5 +26,5 @@ following example, the `greet` router is loaded on two path patterns.
app.use(['/gre+t', '/hel{2}o'], greet) // load the router on '/gre+t' and '/hel{2}o'
```

When a request is made to `/greet/jp`, `req.baseUrl` is "/greet". When a request is
When a request is made to `/greet/jp`, `req.baseUrl` is "/greet". When a request is
made to `/hello/jp`, `req.baseUrl` is "/hello".
2 changes: 1 addition & 1 deletion _includes/api/en/5x/req-cookies.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h3 id='req.cookies'>req.cookies</h3>

When using [cookie-parser](https://www.npmjs.com/package/cookie-parser) middleware, this property is an object that
contains cookies sent by the request. If the request contains no cookies, it defaults to `{}`.
contains cookies sent by the request. If the request contains no cookies, it defaults to `{}`.

```js
// Cookie: name=tj
Expand Down
5 changes: 3 additions & 2 deletions _includes/api/en/5x/req-route.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<h3 id='req.route'>req.route</h3>

Contains the currently-matched route, a string. For example:
Contains the currently-matched route, a string. For example:

```js
app.get('/user/:id?', (req, res) => {
Expand All @@ -21,5 +21,6 @@ Example output from the previous snippet:
keys: [],
regexp: /^\/?$/i,
method: 'get' } ],
methods: { get: true } }
methods: { get: true }
}
```
2 changes: 1 addition & 1 deletion _includes/api/en/5x/req.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h2 id="req">Request</h2>

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,
request query string, parameters, body, HTTP headers, and so on. In this documentation and by convention,
the object is always referred to as `req` (and the HTTP response is `res`) but its actual name is determined
by the parameters to the callback function in which you're working.

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/res-append.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
</div>

Appends the specified `value` to the HTTP response header `field`. If the header is not already set,
it creates the header with the specified value. The `value` parameter can be a string or an array.
it creates the header with the specified value. The `value` parameter can be a string or an array.

Note: calling `res.set()` after `res.append()` will reset the previously-set header value.

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/res-attachment.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<h3 id='res.attachment'>res.attachment([filename])</h3>

Sets the HTTP response `Content-Disposition` header field to "attachment". If a `filename` is given,
then it sets the Content-Type based on the extension name via `res.type()`,
then it sets the `Content-Type` based on the extension name via `res.type()`,
and sets the `Content-Disposition` "filename=" parameter.

```js
Expand Down
4 changes: 2 additions & 2 deletions _includes/api/en/5x/res-cookie.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,10 @@ res.cookie('cart', { items: [1, 2, 3] }, { maxAge: 900000 })

When using [cookie-parser](https://www.npmjs.com/package/cookie-parser) middleware, this method also
supports signed cookies. Simply include the `signed` option set to `true`.
Then `res.cookie()` will use the secret passed to `cookieParser(secret)` to sign the value.
Then, `res.cookie()` will use the secret passed to `cookieParser(secret)` to sign the value.

```js
res.cookie('name', 'tobi', { signed: true })
```

Later you may access this value through the [req.signedCookies](#req.signedCookies) object.
Later, you may access this value through the [req.signedCookies](#req.signedCookies) object.
2 changes: 1 addition & 1 deletion _includes/api/en/5x/res-format.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ The `Content-Type` response header is set when a callback is selected. However,
this within the callback using methods such as `res.set()` or `res.type()`.

The following example would respond with `{ "message": "hey" }` when the `Accept` header field is set
to "application/json" or "\*/json" (however if it is "\*/\*", then the response will be "hey").
to "application/json" or "\*/json" (however, if it is "\*/\*", then the response will be "hey").

```js
res.format({
Expand Down
4 changes: 2 additions & 2 deletions _includes/api/en/5x/res-redirect.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
<h3 id='res.redirect'>res.redirect([status,] path)</h3>

Redirects to the URL derived from the specified `path`, with specified `status`, a positive integer
that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html) .
If not specified, `status` defaults to "302 "Found".
that corresponds to an [HTTP status code](http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
If not specified, `status` defaults to `302 "Found"`.

```js
res.redirect('/foo/bar')
Expand Down
4 changes: 2 additions & 2 deletions _includes/api/en/5x/router-METHOD.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

The `router.METHOD()` methods provide the routing functionality in Express,
where METHOD is one of the HTTP methods, such as GET, PUT, POST, and so on,
in lowercase. Thus, the actual methods are `router.get()`, `router.post()`,
in lowercase. Thus, the actual methods are `router.get()`, `router.post()`,
`router.put()`, and so on.

<div class="doc-box doc-info" markdown="1">
Expand All @@ -13,7 +13,7 @@ in lowercase. Thus, the actual methods are `router.get()`, `router.post()`,

You can provide multiple callbacks, and all are treated equally, and behave just
like middleware, except that these callbacks may invoke `next('route')`
to bypass the remaining route callback(s). You can use this mechanism to perform
to bypass the remaining route callback(s). You can use this mechanism to perform
pre-conditions on a route then pass control to subsequent routes when there is no
reason to proceed with the route matched.

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/router-all.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ router.all('*', requireAuthentication)
router.all('*', loadUser)
```

Another example of this is white-listed "global" functionality. Here
Another example of this is white-listed "global" functionality. Here,
the example is much like before, but it only restricts paths prefixed with
"/api":

Expand Down
2 changes: 1 addition & 1 deletion _includes/api/en/5x/router-route.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,5 @@ This approach re-uses the single `/users/:user_id` path and adds handlers for
various HTTP methods.

<div class="doc-box doc-info" markdown="1">
NOTE: When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added.
NOTE: When you use `router.route()`, middleware ordering is based on when the _route_ is created, not when method handlers are added to the route. For this purpose, you can consider method handlers to belong to the route to which they were added.
</div>
2 changes: 1 addition & 1 deletion _includes/api/en/5x/router-use.md
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,4 @@ app.use('/users', authRouter)
app.use('/users', openRouter)
```

Even though the authentication middleware was added via the `authRouter` it will run on the routes defined by the `openRouter` as well since both routers were mounted on `/users`. To avoid this behavior, use different paths for each router.
Even though the authentication middleware was added via the `authRouter` it will run on the routes defined by the `openRouter` as well since both routers were mounted on `/users`. To avoid this behavior, use different paths for each router.
4 changes: 2 additions & 2 deletions _includes/api/en/5x/router.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ as a "mini-application," capable only of performing middleware and routing
functions. Every Express application has a built-in app router.

A router behaves like middleware itself, so you can use it as an argument to
[app.use()](#app.use) or as the argument to another router's [use()](#router.use) method.
[app.use()](#app.use) or as the argument to another router's [use()](#router.use) method.

The top-level `express` object has a [Router()](#express.router) method that creates a new `router` object.

Once you've created a router object, you can add middleware and HTTP method routes (such as `get`, `put`, `post`,
and so on) to it just like an application. For example:
and so on) to it just like an application. For example:

```js
// invoked for any requests passed to this router
Expand Down
8 changes: 4 additions & 4 deletions en/advanced/best-practice-performance.md
Original file line number Diff line number Diff line change
Expand Up @@ -137,12 +137,12 @@ app.use((err, req, res, next) => {
})
```

Now all errors asynchronous and synchronous get propagated to the error middleware.
Now, all errors asynchronous and synchronous get propagated to the error middleware.

However, there are two caveats:

1. All your asynchronous code must return promises (except emitters). If a particular library does not return promises, convert the base object by using a helper function like [Bluebird.promisifyAll()](http://bluebirdjs.com/docs/api/promise.promisifyall.html).
2. Event emitters (like streams) can still cause uncaught exceptions. So make sure you are handling the error event properly; for example:
2. Event emitters (like `streams`) can still cause uncaught exceptions. So make sure you are handling the error event properly; for example:

```js
const wrap = fn => (...args) => fn(...args).catch(args[2])
Expand Down Expand Up @@ -185,7 +185,7 @@ Setting NODE_ENV to "production" makes Express:

If you need to write environment-specific code, you can check the value of NODE_ENV with `process.env.NODE_ENV`. Be aware that checking the value of any environment variable incurs a performance penalty, and so should be done sparingly.

In development, you typically set environment variables in your interactive shell, for example by using `export` or your `.bash_profile` file. But in general you shouldn't do that on a production server; instead, use your OS's init system (systemd or Upstart). The next section provides more details about using your init system in general, but setting NODE_ENV is so important for performance (and easy to do), that it's highlighted here.
In development, you typically set environment variables in your interactive shell, for example by using `export` or your `.bash_profile` file. But in general, you shouldn't do that on a production server; instead, use your OS's init system (systemd or Upstart). The next section provides more details about using your init system in general, but setting `NODE_ENV` is so important for performance (and easy to do), that it's highlighted here.

With Upstart, use the `env` keyword in your job file. For example:

Expand Down Expand Up @@ -258,7 +258,7 @@ There are two ways to use init systems with your Express app:

Systemd is a Linux system and service manager. Most major Linux distributions have adopted systemd as their default init system.

A systemd service configuration file is called a _unit file_, with a filename ending in `.service`. Here's an example unit file to manage a Node app directly. Replace the values enclosed in `<angle brackets>` for your system and app:
A systemd service configuration file is called a _unit file_, with a filename ending in `.service`. Here's an example unit file to manage a Node app directly. Replace the values enclosed in `<angle brackets>` for your system and app:

```sh
[Unit]
Expand Down
Loading

0 comments on commit 8bc34dd

Please sign in to comment.