fix: content overflow on small screen (#1948)

* update tables in 5.x for consistency in design

* update tables in 4.x for consistency in design

* remove content overflow for mobile devices

* remove inline padding from main conatent

---------

Co-authored-by: Sebastian Beltran <bjohansebas@gmail.com>
This commit is contained in:
shubham oulkar
2025-07-03 06:54:39 +05:30
committed by GitHub
parent c7b12bd06d
commit 7743e0f856
23 changed files with 349 additions and 228 deletions

View File

@@ -10,39 +10,37 @@ PUT, POST, and so on, in lowercase. Thus, the actual methods are `app.get()`,
Express supports the following routing methods corresponding to the HTTP methods of the same names:
<table style="border: 0px; background: none">
<tr>
<td style="background: none; border: 0px;" markdown="1">
* `checkout`
* `copy`
* `delete`
* `get`
* `head`
* `lock`
* `merge`
* `mkactivity`
</td>
<td style="background: none; border: 0px;" markdown="1">
* `mkcol`
* `move`
* `m-search`
* `notify`
* `options`
* `patch`
* `post`
</td>
<td style="background: none; border: 0px;" markdown="1">
* `purge`
* `put`
* `report`
* `search`
* `subscribe`
* `trace`
* `unlock`
* `unsubscribe`
</td>
</tr>
</table>
<div class="methods-columns">
<ul>
<li><code>checkout</code></li>
<li><code>copy</code></li>
<li><code>delete</code></li>
<li><code>get</code></li>
<li><code>head</code></li>
<li><code>lock</code></li>
<li><code>merge</code></li>
<li><code>mkactivity</code></li>
</ul>
<ul>
<li><code>mkcol</code></li>
<li><code>move</code></li>
<li><code>m-search</code></li>
<li><code>notify</code></li>
<li><code>options</code></li>
<li><code>patch</code></li>
<li><code>post</code></li>
</ul>
<ul>
<li><code>purge</code></li>
<li><code>put</code></li>
<li><code>report</code></li>
<li><code>search</code></li>
<li><code>subscribe</code></li>
<li><code>trace</code></li>
<li><code>unlock</code></li>
<li><code>unsubscribe</code></li>
</ul>
</div>
The API documentation has explicit entries only for the most popular HTTP methods `app.get()`,
`app.post()`, `app.put()`, and `app.delete()`.

View File

@@ -9,8 +9,15 @@ Exceptions: Sub-apps will inherit the value of `trust proxy` even though it has
Sub-apps will not inherit the value of `view cache` in production (when `NODE_ENV` is "production").
<div class="table-scroller">
<table class="doctable" border="1">
<thead><tr><th id="app-settings-property">Property</th><th>Type</th><th>Description</th><th>Default</th></tr></thead>
<table>
<thead>
<tr>
<th id="app-settings-property">Property</th>
<th>Type</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td markdown="1">
@@ -193,6 +200,7 @@ A custom query string parsing function will receive the complete query string, a
</tr>
</tbody>
</table>
</div>
<h5 id="trust.proxy.options.table">Options for `trust proxy` setting</h5>
@@ -201,7 +209,8 @@ A custom query string parsing function will receive the complete query string, a
information.
</p>
<table class="doctable" border="1">
<div class="table-scroller">
<table>
<thead><tr><th>Type</th><th>Value</th></tr></thead>
<tbody>
<tr>
@@ -271,6 +280,7 @@ app.set('trust proxy', function (ip) {
</tr>
</tbody>
</table>
</div>
<h5 id="etag.options.table">Options for `etag` setting</h5>
@@ -285,7 +295,8 @@ The [express.static](#express.static) middleware ignores these settings.
For more information, see its documentation.
</p>
<table class="doctable" border="1">
<div class="table-scroller">
<table>
<thead><tr><th>Type</th><th>Value</th></tr></thead>
<tbody>
<tr>

View File

@@ -66,7 +66,7 @@ The following table provides some simple examples of valid `path` values for
mounting middleware.
<div class="table-scroller">
<table class="doctable" border="1">
<table>
<thead>
<tr>
@@ -166,7 +166,7 @@ app.use(['/abcd', '/xyza', /\/lmn|\/pqr/], function (req, res, next) {
The following table provides some simple examples of middleware functions that
can be used as the `callback` argument to `app.use()`, `app.METHOD()`, and `app.all()`.
<table class="doctable" border="1">
<table>
<thead>
<tr>
@@ -282,6 +282,7 @@ app.use(mw1, [mw2, r1, r2], subApp)
</tbody>
</table>
</div>
Following are some examples of using the [express.static](/{{page.lang}}/guide/using-middleware.html#middleware.built-in)
middleware in an Express app.

View File

@@ -26,6 +26,8 @@ For example, `req.body.foo.toString()` may fail in multiple ways, for example
function and instead a string or other user-input.
</div>
<div class="table-scroller" markdown="1">
The following table describes the properties of the optional `options` object.
| Property | Description | Type | Default |
@@ -36,3 +38,5 @@ The following table describes the properties of the optional `options` object.
| `strict` | Enables or disables only accepting arrays and objects; when disabled will accept anything `JSON.parse` accepts. | Boolean | `true` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `json`), a mime type (like `application/json`), or a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/json"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -28,9 +28,13 @@ that `req.body` is a `Buffer` before calling buffer methods is recommended.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|-----------|-----------------------------------------------------------------------|-------------|-----------------|
| `inflate` | Enables or disables handling deflated (compressed) bodies; when disabled, deflated bodies are rejected. | Boolean | `true` |
| `limit` | Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the [bytes](https://www.npmjs.com/package/bytes) library for parsing. | Mixed | `"100kb"` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `bin`), a mime type (like `application/octet-stream`), or a mime type with a wildcard (like `*/*` or `application/*`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/octet-stream"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -16,6 +16,8 @@ to move on to the next middleware, allowing for stacking and fall-backs.
The following table describes the properties of the `options` object.
See also the [example below](#example.of.express.static).
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|---------------|-----------------------------------------------------------------------|-------------|-----------------|
| `dotfiles` | Determines how dotfiles (files or directories that begin with a dot ".") are treated. <br/><br/>See [dotfiles](#dotfiles) below. | String | `undefined` |
@@ -29,6 +31,8 @@ See also the [example below](#example.of.express.static).
| `redirect` | Redirect to trailing "/" when the pathname is a directory. | Boolean | `true` |
| `setHeaders` | Function for setting HTTP headers to serve with the file. <br/><br/>See [setHeaders](#setHeaders) below. | Function | |
</div>
For more information, see [Serving static files in Express](/starter/static-files.html).
and [Using middleware - Built-in middleware](/{{page.lang}}/guide/using-middleware.html#middleware.built-in).

View File

@@ -28,6 +28,8 @@ that `req.body` is a string before calling string methods is recommended.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|------------------|-----------------------------------------------------------------------|-------------|-----------------|
| `defaultCharset` | Specify the default character set for the text content if the charset is not specified in the `Content-Type` header of the request. | String | `"utf-8"` |
@@ -35,3 +37,5 @@ The following table describes the properties of the optional `options` object.
| `limit` | Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the [bytes](https://www.npmjs.com/package/bytes) library for parsing. | Mixed | `"100kb"` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `txt`), a mime type (like `text/plain`), or a mime type with a wildcard (like `*/*` or `text/*`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"text/plain"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -29,6 +29,8 @@ function and instead a string or other user-input.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|------------------|-----------------------------------------------------------------------|-------------|-----------------|
| `extended` | This option allows to choose between parsing the URL-encoded data with the `querystring` library (when `false`) or the `qs` library (when `true`). The "extended" syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded. For more information, please [see the qs library](https://www.npmjs.org/package/qs#readme). | Boolean | `true` |
@@ -37,3 +39,5 @@ The following table describes the properties of the optional `options` object.
| `parameterLimit` | This option controls the maximum number of parameters that are allowed in the URL-encoded data. If a request contains more parameters than this value, an error will be raised. | Number | `1000` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `urlencoded`), a mime type (like `application/x-www-form-urlencoded`), or a mime type with a wildcard (like `*/x-www-form-urlencoded`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/x-www-form-urlencoded"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -6,9 +6,13 @@ The `size` parameter is the maximum size of the resource.
The `options` parameter is an object that can have the following properties.
<div class="table-scroller" markdown="1">
| Property | Type | Description |
|-------------|-------------------------------------------------------------------------|
| `combine` | Boolean | Specify if overlapping & adjacent ranges should be combined, defaults to `false`. When `true`, ranges will be combined and returned as if they were specified that way in the header.
| `combine` | Boolean | Specify if overlapping & adjacent ranges should be combined, defaults to `false`. When `true`, ranges will be combined and returned as if they were specified that way in the header.|
</div>
An array of ranges will be returned or negative numbers indicating an error parsing.

View File

@@ -4,19 +4,23 @@ Sets cookie `name` to `value`. The `value` parameter may be a string or object
The `options` parameter is an object that can have the following properties.
<div class="table-scroller" markdown="1">
| Property | Type | Description |
|---------------|-------------------------------------------------------------------------|
| `domain` | String | Domain name for the cookie. Defaults to the domain name of the app.
| `encode` | Function | A synchronous function used for cookie value encoding. Defaults to `encodeURIComponent`.
| `expires` | Date | Expiry date of the cookie in GMT. If not specified or set to 0, creates a session cookie.
| `httpOnly` | Boolean | Flags the cookie to be accessible only by the web server.
| `maxAge` | Number | Convenient option for setting the expiry time relative to the current time in milliseconds.
| `path` | String | Path for the cookie. Defaults to "/".
| `partitioned` | Boolean | Indicates that the cookie should be stored using partitioned storage. See [Cookies Having Independent Partitioned State (CHIPS)](https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies) for more details.
| `priority` | String | Value of the "Priority" **Set-Cookie** attribute.
| `secure` | Boolean | Marks the cookie to be used with HTTPS only.
| `signed` | Boolean | Indicates if the cookie should be signed.
| `sameSite` | Boolean or String | Value of the "SameSite" **Set-Cookie** attribute. More information at [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1).
| `domain` | String | Domain name for the cookie. Defaults to the domain name of the app.|
| `encode` | Function | A synchronous function used for cookie value encoding. Defaults to `encodeURIComponent`.|
| `expires` | Date | Expiry date of the cookie in GMT. If not specified or set to 0, creates a session cookie.|
| `httpOnly` | Boolean | Flags the cookie to be accessible only by the web server.|
| `maxAge` | Number | Convenient option for setting the expiry time relative to the current time in milliseconds.|
| `path` | String | Path for the cookie. Defaults to "/".|
| `partitioned` | Boolean | Indicates that the cookie should be stored using partitioned storage. See [Cookies Having Independent Partitioned State (CHIPS)](https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies) for more details.|
| `priority` | String | Value of the "Priority" **Set-Cookie** attribute.|
| `secure` | Boolean | Marks the cookie to be used with HTTPS only.|
| `signed` | Boolean | Indicates if the cookie should be signed.|
| `sameSite` | Boolean or String | Value of the "SameSite" **Set-Cookie** attribute. More information at [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1).|
</div>
<div class="doc-box doc-notice" markdown="1">
All `res.cookie()` does is set the HTTP `Set-Cookie` header with the options provided.

View File

@@ -1,49 +1,55 @@
<h4> Arguments</h4>
<h4>Arguments</h4>
<table class="doctable" border="1" style="padding-left: 20px;">
<tr>
<th>Argument </th>
<th> Description </th>
<th style="width: 100px;"> Default </th>
</tr>
<tr>
<td><code>path</code></td>
<td>
The path for which the middleware function is invoked; can be any of:
<ul>
<li>A string representing a path.</li>
<li>A path pattern.</li>
<li>A regular expression pattern to match paths.</li>
<li>An array of combinations of any of the above.</li>
</ul>
For examples, see <a href="#path-examples">Path examples</a>.
</td>
<td>'/' (root path)</td>
</tr>
<tr>
<td> <code>callback</code></td>
<td>
Callback functions; can be:
<ul>
<li>A middleware function.</li>
<li>A series of middleware functions (separated by commas).</li>
<li>An array of middleware functions.</li>
<li>A combination of all of the above.</li>
</ul>
<p>
You can provide multiple callback functions that behave just like middleware, except
that these callbacks can invoke <code>next('route')</code> to bypass
the remaining route callback(s). You can use this mechanism to impose pre-conditions
on a route, then pass control to subsequent routes if there is no reason to proceed with the current route.
</p><p>
Since <a href="#router">router</a> and <a href="#application">app</a> implement the middleware interface,
you can use them as you would any other middleware function.
</p><p>
For examples, see <a href="#middleware-callback-function-examples">Middleware callback function examples</a>.
</p>
</td>
<td> None </td>
</tr></table>
<div class="table-scroller">
<table>
<thead>
<tr>
<th scope="col">Argument</th>
<th scope="col">Description</th>
<th scope="col">Default</th>
</tr>
</thead>
<tbody>
<tr>
<th scope="row"><code>path</code></th>
<td>
The path for which the middleware function is invoked; can be any of:
<ul>
<li>A string representing a path.</li>
<li>A path pattern.</li>
<li>A regular expression pattern to match paths.</li>
<li>An array of combinations of any of the above.</li>
</ul>
For examples, see <a href="#path-examples">Path examples</a>.
</td>
<td>'/' (root path)</td>
</tr>
<tr>
<th scope="row"><code>callback</code></th>
<td>
Callback functions; can be:
<ul>
<li>A middleware function.</li>
<li>A series of middleware functions (separated by commas).</li>
<li>An array of middleware functions.</li>
<li>A combination of all of the above.</li>
</ul>
<p>
You can provide multiple callback functions that behave just like middleware, except
that these callbacks can invoke <code>next('route')</code> to bypass
the remaining route callback(s). You can use this mechanism to impose pre-conditions
on a route, then pass control to subsequent routes if there is no reason to proceed with the current route.
</p>
<p>
Since <a href="#router">router</a> and <a href="#application">app</a> implement the middleware interface,
you can use them as you would any other middleware function.
</p>
<p>
For examples, see <a href="#middleware-callback-function-examples">Middleware callback function examples</a>.
</p>
</td>
<td>None</td>
</tr>
</tbody>
</table>
</div>

View File

@@ -10,39 +10,37 @@ PUT, POST, and so on, in lowercase. Thus, the actual methods are `app.get()`,
Express supports the following routing methods corresponding to the HTTP methods of the same names:
<table style="border: 0px; background: none">
<tr>
<td style="background: none; border: 0px;" markdown="1">
* `checkout`
* `copy`
* `delete`
* `get`
* `head`
* `lock`
* `merge`
* `mkactivity`
</td>
<td style="background: none; border: 0px;" markdown="1">
* `mkcol`
* `move`
* `m-search`
* `notify`
* `options`
* `patch`
* `post`
</td>
<td style="background: none; border: 0px;" markdown="1">
* `purge`
* `put`
* `report`
* `search`
* `subscribe`
* `trace`
* `unlock`
* `unsubscribe`
</td>
</tr>
</table>
<div class="methods-columns">
<ul>
<li><code>checkout</code></li>
<li><code>copy</code></li>
<li><code>delete</code></li>
<li><code>get</code></li>
<li><code>head</code></li>
<li><code>lock</code></li>
<li><code>merge</code></li>
<li><code>mkactivity</code></li>
</ul>
<ul>
<li><code>mkcol</code></li>
<li><code>move</code></li>
<li><code>m-search</code></li>
<li><code>notify</code></li>
<li><code>options</code></li>
<li><code>patch</code></li>
<li><code>post</code></li>
</ul>
<ul>
<li><code>purge</code></li>
<li><code>put</code></li>
<li><code>report</code></li>
<li><code>search</code></li>
<li><code>subscribe</code></li>
<li><code>trace</code></li>
<li><code>unlock</code></li>
<li><code>unsubscribe</code></li>
</ul>
</div>
The API documentation has explicit entries only for the most popular HTTP methods `app.get()`,
`app.post()`, `app.put()`, and `app.delete()`.

View File

@@ -9,7 +9,7 @@ Exceptions: Sub-apps will inherit the value of `trust proxy` even though it has
Sub-apps will not inherit the value of `view cache` in production (when `NODE_ENV` is "production").
<div class="table-scroller">
<table class="doctable" border="1">
<table>
<thead><tr><th id="app-settings-property">Property</th><th>Type</th><th>Description</th><th>Default</th></tr></thead>
<tbody>
<tr>
@@ -194,6 +194,7 @@ A custom query string parsing function will receive the complete query string, a
</tr>
</tbody>
</table>
</div>
<h5 id="trust.proxy.options.table">Options for `trust proxy` setting</h5>
@@ -202,7 +203,8 @@ A custom query string parsing function will receive the complete query string, a
information.
</p>
<table class="doctable" border="1">
<div class="table-scroller">
<table>
<thead><tr><th>Type</th><th>Value</th></tr></thead>
<tbody>
<tr>
@@ -272,6 +274,7 @@ app.set('trust proxy', (ip) => {
</tr>
</tbody>
</table>
</div>
<h5 id="etag.options.table">Options for `etag` setting</h5>
@@ -286,7 +289,8 @@ The [express.static](#express.static) middleware ignores these settings.
For more information, see its documentation.
</p>
<table class="doctable" border="1">
<div class="table-scroller">
<table>
<thead><tr><th>Type</th><th>Value</th></tr></thead>
<tbody>
<tr>

View File

@@ -66,7 +66,7 @@ The following table provides some simple examples of valid `path` values for
mounting middleware.
<div class="table-scroller">
<table class="doctable" border="1">
<table>
<thead>
<tr>
@@ -143,7 +143,8 @@ app.use(['/abcd', '/xyza', /\/lmn|\/pqr/], (req, res, next) => {
The following table provides some simple examples of middleware functions that
can be used as the `callback` argument to `app.use()`, `app.METHOD()`, and `app.all()`.
<table class="doctable" border="1">
<div class="table-scroller">
<table>
<thead>
<tr>
@@ -258,6 +259,7 @@ app.use(mw1, [mw2, r1, r2], subApp)
</tbody>
</table>
</div>
Following are some examples of using the [express.static](/{{page.lang}}/guide/using-middleware.html#middleware.built-in)
middleware in an Express app.

View File

@@ -24,6 +24,8 @@ function and instead a string or other user-input.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|---------------|-----------------------------------------------------------------------|-------------|-----------------|
| `inflate` | Enables or disables handling deflated (compressed) bodies; when disabled, deflated bodies are rejected. | Boolean | `true` |
@@ -32,3 +34,5 @@ The following table describes the properties of the optional `options` object.
| `strict` | Enables or disables only accepting arrays and objects; when disabled will accept anything `JSON.parse` accepts. | Boolean | `true` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `json`), a mime type (like `application/json`), or a mime type with a wildcard (like `*/*` or `*/json`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/json"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -24,9 +24,13 @@ that `req.body` is a `Buffer` before calling buffer methods is recommended.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|-----------|-----------------------------------------------------------------------|-------------|-----------------|
| `inflate` | Enables or disables handling deflated (compressed) bodies; when disabled, deflated bodies are rejected. | Boolean | `true` |
| `limit` | Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the [bytes](https://www.npmjs.com/package/bytes) library for parsing. | Mixed | `"100kb"` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `bin`), a mime type (like `application/octet-stream`), or a mime type with a wildcard (like `*/*` or `application/*`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/octet-stream"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -14,6 +14,8 @@ to move on to the next middleware, allowing for stacking and fall-backs.
The following table describes the properties of the `options` object.
See also the [example below](#example.of.express.static).
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|---------------|-----------------------------------------------------------------------|-------------|-----------------|
| `dotfiles` | Determines how dotfiles (files or directories that begin with a dot ".") are treated. <br/><br/>See [dotfiles](#dotfiles) below. | String | "ignore"|
@@ -27,6 +29,8 @@ See also the [example below](#example.of.express.static).
| `redirect` | Redirect to trailing "/" when the pathname is a directory. | Boolean | `true` |
| `setHeaders` | Function for setting HTTP headers to serve with the file. <br/><br/>See [setHeaders](#setHeaders) below. | Function | |
</div>
For more information, see [Serving static files in Express](/starter/static-files.html).
and [Using middleware - Built-in middleware](/{{page.lang}}/guide/using-middleware.html#middleware.built-in).

View File

@@ -24,6 +24,8 @@ that `req.body` is a string before calling string methods is recommended.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|------------------|-----------------------------------------------------------------------|-------------|-----------------|
| `defaultCharset` | Specify the default character set for the text content if the charset is not specified in the `Content-Type` header of the request. | String | `"utf-8"` |
@@ -31,3 +33,5 @@ The following table describes the properties of the optional `options` object.
| `limit` | Controls the maximum request body size. If this is a number, then the value specifies the number of bytes; if it is a string, the value is passed to the [bytes](https://www.npmjs.com/package/bytes) library for parsing. | Mixed | `"100kb"` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `txt`), a mime type (like `text/plain`), or a mime type with a wildcard (like `*/*` or `text/*`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"text/plain"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -25,6 +25,8 @@ function and instead a string or other user-input.
The following table describes the properties of the optional `options` object.
<div class="table-scroller" markdown="1">
| Property | Description | Type | Default |
|------------------|-----------------------------------------------------------------------|-------------|-----------------|
| `extended` | This option allows to choose between parsing the URL-encoded data with the `querystring` library (when `false`) or the `qs` library (when `true`). The "extended" syntax allows for rich objects and arrays to be encoded into the URL-encoded format, allowing for a JSON-like experience with URL-encoded. For more information, please [see the qs library](https://www.npmjs.org/package/qs#readme). | Boolean | `false` |
@@ -33,3 +35,5 @@ The following table describes the properties of the optional `options` object.
| `parameterLimit` | This option controls the maximum number of parameters that are allowed in the URL-encoded data. If a request contains more parameters than this value, an error will be raised. | Number | `1000` |
| `type` | This is used to determine what media type the middleware will parse. This option can be a string, array of strings, or a function. If not a function, `type` option is passed directly to the [type-is](https://www.npmjs.org/package/type-is#readme) library and this can be an extension name (like `urlencoded`), a mime type (like `application/x-www-form-urlencoded`), or a mime type with a wildcard (like `*/x-www-form-urlencoded`). If a function, the `type` option is called as `fn(req)` and the request is parsed if it returns a truthy value. | Mixed | `"application/x-www-form-urlencoded"` |
| `verify` | This option, if supplied, is called as `verify(req, res, buf, encoding)`, where `buf` is a `Buffer` of the raw request body and `encoding` is the encoding of the request. The parsing can be aborted by throwing an error. | Function | `undefined` |
</div>

View File

@@ -6,9 +6,13 @@ The `size` parameter is the maximum size of the resource.
The `options` parameter is an object that can have the following properties.
<div class="table-scroller" markdown="1">
| Property | Type | Description |
|-------------|-------------------------------------------------------------------------|
| `combine` | Boolean | Specify if overlapping & adjacent ranges should be combined, defaults to `false`. When `true`, ranges will be combined and returned as if they were specified that way in the header.
| `combine` | Boolean | Specify if overlapping & adjacent ranges should be combined, defaults to `false`. When `true`, ranges will be combined and returned as if they were specified that way in the header.|
</div>
An array of ranges will be returned or negative numbers indicating an error parsing.

View File

@@ -4,19 +4,23 @@ Sets cookie `name` to `value`. The `value` parameter may be a string or object
The `options` parameter is an object that can have the following properties.
<div class="table-scroller" markdown="1">
| Property | Type | Description |
|---------------|-------------------------------------------------------------------------|
| `domain` | String | Domain name for the cookie. Defaults to the domain name of the app.
| `encode` | Function | A synchronous function used for cookie value encoding. Defaults to `encodeURIComponent`.
| `expires` | Date | Expiry date of the cookie in GMT. If not specified or set to 0, creates a session cookie.
| `httpOnly` | Boolean | Flags the cookie to be accessible only by the web server.
| `maxAge` | Number | Convenient option for setting the expiry time relative to the current time in milliseconds.
| `path` | String | Path for the cookie. Defaults to "/".
| `partitioned` | Boolean | Indicates that the cookie should be stored using partitioned storage. See [Cookies Having Independent Partitioned State (CHIPS)](https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies) for more details.
| `priority` | String | Value of the "Priority" **Set-Cookie** attribute.
| `secure` | Boolean | Marks the cookie to be used with HTTPS only.
| `signed` | Boolean | Indicates if the cookie should be signed.
| `sameSite` | Boolean or String | Value of the "SameSite" **Set-Cookie** attribute. More information at [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1).
| `domain` | String | Domain name for the cookie. Defaults to the domain name of the app.|
| `encode` | Function | A synchronous function used for cookie value encoding. Defaults to `encodeURIComponent`.|
| `expires` | Date | Expiry date of the cookie in GMT. If not specified or set to 0, creates a session cookie.|
| `httpOnly` | Boolean | Flags the cookie to be accessible only by the web server.|
| `maxAge` | Number | Convenient option for setting the expiry time relative to the current time in milliseconds.|
| `path` | String | Path for the cookie. Defaults to "/".|
| `partitioned` | Boolean | Indicates that the cookie should be stored using partitioned storage. See [Cookies Having Independent Partitioned State (CHIPS)](https://developer.mozilla.org/en-US/docs/Web/Privacy/Partitioned_cookies) for more details.|
| `priority` | String | Value of the "Priority" **Set-Cookie** attribute.|
| `secure` | Boolean | Marks the cookie to be used with HTTPS only.|
| `signed` | Boolean | Indicates if the cookie should be signed.|
| `sameSite` | Boolean or String | Value of the "SameSite" **Set-Cookie** attribute. More information at [https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1](https://tools.ietf.org/html/draft-ietf-httpbis-cookie-same-site-00#section-4.1.1).|
</div>
<div class="doc-box doc-notice" markdown="1">
All `res.cookie()` does is set the HTTP `Set-Cookie` header with the options provided.

View File

@@ -1,51 +1,58 @@
<h4> Arguments</h4>
<h4>Arguments</h4>
<table class="doctable" border="1" style="padding-left: 20px;">
<tr>
<th>Argument </th>
<th> Description </th>
<th style="width: 100px;"> Default </th>
</tr>
<div class="table-scroller">
<table>
<thead>
<tr>
<th>Argument</th>
<th>Description</th>
<th>Default</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>path</code></td>
<td>
The path for which the middleware function is invoked. It can be any of the following:
<ul>
<li>A string representing a path.</li>
<li>A path pattern.</li>
<li>A regular expression pattern to match paths.</li>
<li>An array containing any combination of the above.</li>
</ul>
For examples, see <a href="#path-examples">Path examples</a>.
</td>
<td><code>'/'</code> (root path)</td>
</tr>
<tr>
<td><code>path</code></td>
<td>
The path for which the middleware function is invoked; can be any of:
<ul>
<li>A string representing a path.</li>
<li>A path pattern.</li>
<li>A regular expression pattern to match paths.</li>
<li>An array of combinations of any of the above.</li>
</ul>
For examples, see <a href="#path-examples">Path examples</a>.
</td>
<td>'/' (root path)</td>
</tr>
<tr>
<td> <code>callback</code></td>
<td>
Callback functions; can be:
<ul>
<li>A middleware function.</li>
<li>A series of middleware functions (separated by commas).</li>
<li>An array of middleware functions.</li>
<li>A combination of all of the above.</li>
</ul>
<p>
You can provide multiple callback functions that behave just like middleware, except
that these callbacks can invoke <code>next('route')</code> to bypass
the remaining route callback(s). You can use this mechanism to impose pre-conditions
on a route, then pass control to subsequent routes if there is no reason to proceed with the current route.
</p><p>
When a callback function throws an error or returns a rejected promise, `next(err)` will be invoked automatically.
</p><p>
Since <a href="#router">router</a> and <a href="#application">app</a> implement the middleware interface,
you can use them as you would any other middleware function.
</p><p>
For examples, see <a href="#middleware-callback-function-examples">Middleware callback function examples</a>.
</p>
</td>
<td> None </td>
</tr></table>
<tr>
<td><code>callback</code></td>
<td>
One or more callback functions. Accepted formats:
<ul>
<li>A single middleware function.</li>
<li>Multiple middleware functions separated by commas.</li>
<li>An array of middleware functions.</li>
<li>A combination of the above.</li>
</ul>
<p>
You may provide multiple callbacks that behave like middleware. These can call
<code>next('route')</code> to skip remaining callbacks for the current route.
This is useful for conditional routing logic.
</p>
<p>
If a callback throws an error or returns a rejected promise, <code>next(err)</code> is invoked automatically.
</p>
<p>
Since both <a href="#router">router</a> and <a href="#application">app</a> implement the middleware interface,
they can also be used as callback middleware.
</p>
<p>
For examples, see <a href="#middleware-callback-function-examples">Middleware callback function examples</a>.
</p>
</td>
<td><em>None</em></td>
</tr>
</tbody>
</table>
</div>

View File

@@ -9,6 +9,23 @@ body {
margin: 0;
padding: 0;
color: var(--fg);
display: grid;
grid-template-areas:
'header'
'content'
'footer'
}
header {
grid-area: header;
}
.content {
grid-area: content;
}
footer {
grid-area: footer;
}
body.no-scroll{
@@ -75,10 +92,6 @@ main.home {
display: flex;
}
.en-doc #home-content {
margin-top: 150px;
}
.non-en-doc:has(#i18n-notice-box.hidden) #home-content {
margin-top: 150px;
}
@@ -157,13 +170,13 @@ main.home {
}
.content {
margin: 153px 0 7%;
display: flex;
flex-direction: row-reverse;
padding-inline-start: 1rem;
margin-block-start: 3.5rem;
}
.content main {
padding-inline: 16px;
max-width: 900px;
margin-inline: auto;
}
@@ -315,17 +328,12 @@ a {
}
header {
position: fixed;
top: 0;
left: 0;
background: var(--card-bg);
width: 100%;
height: 57px;
display: flex;
align-items: center;
justify-content: space-between;
padding-inline: 25px;
z-index: 200;
padding-inline: 1.5rem;
border-bottom: 1px solid var(--hover-fg);
}
@@ -550,36 +558,39 @@ html[xmlns] .clearfix {
list-style: none;
}
/* doc specific */
/* tables specific */
.doctable, table {
table {
margin: 1em 0;
border: 1px solid var(--border);
border-collapse: collapse;
width: 100%;
@media screen and (max-width:600px) {
font-size: smaller;
}
}
.doctable td, .doctable th, table td, table th {
table td, table th {
padding: 7px;
line-height: 120%;
vertical-align: top;
border: 1px solid var(--border);
}
.doctable tr th, table tr th {
table tr th {
background: var(--card-bg);
font-size: 110%;
}
.doctable td p:first-child {
table td p:first-child {
margin-top: 0;
}
.doctable td p, li p {
table td p, li p {
width: 100% !important;
}
.doctable ul {
table ul {
margin: 20px 0
}
@@ -692,12 +703,15 @@ pre, code {
white-space: pre-wrap !important;
}
/* footer */
footer {
font-size: 12px;
margin: 60px 5% 30px;
display: flex;
gap: 24px;
flex-direction: column;
padding-block: 2rem;
padding-inline: 3rem;
}
#footer-content {
@@ -722,7 +736,7 @@ footer {
max-width: 125px;
}
#footer-policy{
#footer-policy {
display: flex;
flex-wrap: wrap;
column-gap: 20px;
@@ -731,15 +745,21 @@ footer {
font-size: 15px;
}
#footer-links{
#footer-links {
display: flex;
gap: 20px;
flex-wrap: wrap;
}
.footer-social {
display: flex;
gap: 20px;
font-size: 20px;
@media screen and (max-width: 340px) {
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 2.5rem;
}
}
/* theme and lang btn */
@@ -1139,6 +1159,19 @@ h2 a {
}
}
/* routing methods columns */
.methods-columns {
display: flex;
gap: 2rem;
justify-content: space-between;
flex-wrap: wrap;
@media screen and (max-width: 460px) {
flex-direction: column;
gap: 0.3rem;
}
}
/* responsive */
@media all and (max-width: 1440px) {
@@ -1288,18 +1321,28 @@ h2 a {
/* TOC responsive */
@media all and (max-width: 800px) {
.content {
margin-inline: 0.5rem;
margin-block-start: 100px;
flex-direction: column;
padding-inline-start : 0;
margin-block-start: 1rem;
}
.content main {
padding-inline: 1rem;
width: 100vw;
margin-top: 0;
margin-inline: 0;
}
#api-doc,
#blog-doc,
#page-doc {
padding-inline: 1rem;
width: 100%;
}
#api-doc section {
padding-left: 0;
}
.toc-container {
display: flex;
flex-direction: column;
@@ -1605,11 +1648,6 @@ blockquote {
}
@media all and (max-width: 1110px) {
header {
column-gap: 12px;
padding-inline: 32px;
}
.desktop-lang-switcher {
display: none;
}