Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 23 additions & 24 deletions src/content/api/4x/api/application/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -264,9 +264,8 @@ app.use('/admin', admin);
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -337,9 +336,8 @@ app.all('/api/*', requireAuthentication);
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -568,9 +566,8 @@ app.get('title');
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -719,9 +716,8 @@ All the forms of Node's [http.Server.listen()](https://nodejs.org/api/http.html#
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand All @@ -741,6 +737,12 @@ Routes an HTTP request, where METHOD is the HTTP method of the request, such as
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.

String route patterns match the whole request path. For example, `app.get('/apple', ...)` matches
`/apple`, but not `/apple/images`. With the same path, [app.use()](#appuse) matches both.

Regular expressions can match part of the path. `app.get(/apple/, ...)` matches `/apple/images`.
Use `^` and `$` for a full match: `app.get(/^\/apple$/, ...)` matches only `/apple`.

#### Routing methods

Express supports the following routing methods corresponding to the HTTP methods of the same names:
Expand Down Expand Up @@ -830,9 +832,8 @@ For more information on routing, see the [routing guide](/guide/routing/).
<Signature runtime={{ 'Node.js': '>=20.19.3 <21 || >=22.2.0' }}>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1203,9 +1204,8 @@ it is usually better to use [req.baseUrl](/api/request/#reqbaseurl) to get the c
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1245,9 +1245,8 @@ app.post('/', function (req: Request, res: Response) {
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1651,9 +1650,9 @@ the middleware function is executed when the base of the requested path matches

#### Description

A route will match any path that follows its path immediately with a "`/`".
For example: `app.use('/apple', ...)` will match "/apple", "/apple/images",
"/apple/images/news", and so on.
With a string path, `app.use()` matches that path and its subpaths. For example,
`app.use('/apple', ...)` matches `/apple`, `/apple/images`, and `/apple/images/news`,
but not `/apples`.

Since `path` defaults to "/", middleware mounted without a path will be executed for every request to the app.
For example, this middleware function will be executed for _every_ request to the app:
Expand Down
47 changes: 23 additions & 24 deletions src/content/api/5x/api/application/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -312,9 +312,8 @@ app.use('/admin', admin);
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -385,9 +384,8 @@ app.all('/api/{*splat}', requireAuthentication);
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -593,9 +591,8 @@ app.get('title');
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -763,9 +760,8 @@ actually supported.
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand All @@ -785,6 +781,12 @@ Routes an HTTP request, where METHOD is the HTTP method of the request, such as
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.

String route patterns match the whole request path. For example, `app.get('/apple', ...)` matches
`/apple`, but not `/apple/images`. With the same path, [app.use()](#appuse) matches both.

Regular expressions can match part of the path. `app.get(/apple/, ...)` matches `/apple/images`.
Use `^` and `$` for a full match: `app.get(/^\/apple$/, ...)` matches only `/apple`.

#### Routing methods

Express supports the following routing methods corresponding to the HTTP methods of the same names:
Expand Down Expand Up @@ -1041,9 +1043,8 @@ it is usually better to use [req.baseUrl](/api/request/#reqbaseurl) to get the c
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1083,9 +1084,8 @@ app.post('/', (req: Request, res: Response) => {
<Signature>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1124,9 +1124,8 @@ app.put('/', (req: Request, res: Response) => {
<Signature runtime={{ 'Node.js': '>=20.19.3 <21 || >=22.2.0' }}>
<Fragment slot="attributes">
<Param name="path" type="String | RegExp | Array">
The path for which the middleware function is invoked; can be any of: a string representing a
path, a path pattern, a regular expression pattern to match paths, or an array of combinations
of any of the above. For examples, see [Path examples](#path-examples).
The path to match for this route: a string, a regular expression, or an array of either.
String patterns match the whole request path. See [Path examples](#path-examples) for syntax.
</Param>
<Param name="callback" type="Function | Function[]">
Callback functions; can be: a middleware function, a series of middleware functions (separated
Expand Down Expand Up @@ -1560,9 +1559,9 @@ the middleware function is executed when the base of the requested path matches

#### Description

A route will match any path that follows its path immediately with a "`/`".
For example: `app.use('/apple', ...)` will match "/apple", "/apple/images",
"/apple/images/news", and so on.
With a string path, `app.use()` matches that path and its subpaths. For example,
`app.use('/apple', ...)` matches `/apple`, `/apple/images`, and `/apple/images/news`,
but not `/apples`.

Since `path` defaults to "/", middleware mounted without a path will be executed for every request to the app.
For example, this middleware function will be executed for _every_ request to the app:
Expand Down
Loading