Skip to content
Open
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
56 changes: 46 additions & 10 deletions src/config/menu/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,15 @@ export const apiMenu: Menu = {
label: 'app.get(path)',
omitFrom: ['3x'],
},
{
href: '/api/application#applisten',
label: 'app.listen()',
omitFrom: ['4x', '5x'],
},
{
href: '/api/application#applistenport-host-backlog-callback',
label: 'app.listen()',
omitFrom: ['3x'],
},
{
href: '/api/application#appmethodpath-callback--callback-',
Expand Down Expand Up @@ -148,7 +154,16 @@ export const apiMenu: Menu = {
omitFrom: ['3x'],
},
{ href: '/api/application#appsetname-value', label: 'app.set()' },
{ href: '/api/application#appusepath-callback--callback', label: 'app.use()' },
{
href: '/api/application#appusepath-function',
label: 'app.use()',
omitFrom: ['4x', '5x'],
},
{
href: '/api/application#appusepath-callback--callback',
label: 'app.use()',
omitFrom: ['3x'],
},
{
href: '/api/application#appverbpath-callback-callback',
label: 'app.VERB()',
Expand Down Expand Up @@ -292,17 +307,17 @@ export const apiMenu: Menu = {
label: 'req.acceptsLanguages()',
omitFrom: ['3x'],
},
{ href: '/api/request#reqgetfield', label: 'req.get()', omitFrom: ['3x'] },
{ href: '/api/request#reqgetfield', label: 'req.get()' },
{ href: '/api/request#reqistype', label: 'req.is()' },
{
href: '/api/request#reqheaderfield',
label: 'req.header()',
href: '/api/request#reqparamname',
label: 'req.param()',
omitFrom: ['4x', '5x'],
},
{ href: '/api/request#reqistype', label: 'req.is()' },
{
href: '/api/request#reqparamname',
href: '/api/request#reqparamname--defaultvalue',
label: 'req.param()',
omitFrom: ['5x'],
omitFrom: ['3x', '5x'],
},
{
href: '/api/request#reqrangesize-options',
Expand Down Expand Up @@ -361,9 +376,15 @@ export const apiMenu: Menu = {
{ href: '/api/response#resattachmentfilename', label: 'res.attachment()' },
{ href: '/api/response#resclearcookiename--options', label: 'res.clearCookie()' },
{ href: '/api/response#rescookiename-value--options', label: 'res.cookie()' },
{
href: '/api/response#resdownloadpath-filename-fn',
label: 'res.download()',
omitFrom: ['4x', '5x'],
},
{
href: '/api/response#resdownloadpath--filename--options--fn',
label: 'res.download()',
omitFrom: ['3x'],
},
{
href: '/api/response#resenddata-encoding-callback',
Expand All @@ -372,13 +393,28 @@ export const apiMenu: Menu = {
},
{ href: `/api/response#resformatobject`, label: 'res.format()' },
{ href: '/api/response#resgetfield', label: 'res.get()' },
{ href: `/api/response#resjsonbody`, label: 'res.json()' },
{ href: '/api/response#resjsonpbody', label: 'res.jsonp()' },
{
href: `/api/response#resjsonstatusbody-body`,
label: 'res.json()',
omitFrom: ['4x', '5x'],
},
{ href: `/api/response#resjsonbody`, label: 'res.json()', omitFrom: ['3x'] },
{
href: '/api/response#resjsonpstatusbody-body',
label: 'res.jsonp()',
omitFrom: ['4x', '5x'],
},
{ href: '/api/response#resjsonpbody', label: 'res.jsonp()', omitFrom: ['3x'] },
{ href: '/api/response#reslinkslinks', label: 'res.links()' },
{ href: '/api/response#reslocationpath', label: 'res.location()' },
{ href: '/api/response#resredirectstatus-path', label: 'res.redirect()' },
{ href: `/api/response#resrenderview--locals--callback`, label: 'res.render()' },
{ href: `/api/response#ressendbody`, label: 'res.send()' },
{
href: `/api/response#ressendbodystatus-body`,
label: 'res.send()',
omitFrom: ['4x', '5x'],
},
{ href: `/api/response#ressendbody`, label: 'res.send()', omitFrom: ['3x'] },
{
href: '/api/response#ressendfilepath-options-fn',
label: 'res.sendfile()',
Expand Down
4 changes: 2 additions & 2 deletions src/content/api/3x/api/application/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ app.post('/forum/:fid/thread/:tid', middleware, function () {
});
```

### app.all(path, [callback...], callback)
### app.all(path, callback [, callback ...])

This method functions just like the `app.VERB()` methods,
however it matches all HTTP verbs.
Expand Down Expand Up @@ -521,7 +521,7 @@ the example is much like before, however only restricting paths prefixed with
app.all('/api/*', requireAuthentication);
```

### app.render(view, [options], callback)
### app.render(view, [locals], callback)

Render a `view` with a callback responding with
the rendered string. This is the app-level variant of `res.render()`,
Expand Down
19 changes: 10 additions & 9 deletions src/content/api/3x/api/response/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ res.attachment('path/to/logo.png');
// Content-Type: image/png
```

### res.clearCookie(name, [options])
### res.clearCookie(name [, options])

Clear cookie `name`. The `path` option defaults to "/".

Expand All @@ -71,7 +71,7 @@ res.cookie('name', 'tobi', { path: '/admin' });
res.clearCookie('name', { path: '/admin' });
```

### res.cookie(name, value, [options])
### res.cookie(name, value [, options])

Set cookie `name` to `value`, which may be a string or object converted to JSON. The `path`
option defaults to "/".
Expand Down Expand Up @@ -264,7 +264,7 @@ Link: <http://api.example.com/users?page=2> rel="next",
<http://api.example.com/users?page=5> rel="last"
```

### res.location()
### res.location(path)

Set the location header.

Expand All @@ -276,7 +276,7 @@ res.location('../login');
res.location('back');
```

You can use the same kind of `urls` as in `res.redirect()`.
You can use the same kind of `path` as in `res.redirect()`.

For example, if your application is mounted at `/blog`,
the following would set the `location` header to
Expand All @@ -286,10 +286,11 @@ the following would set the `location` header to
res.location('admin');
```

### res.redirect([status], url)
### res.redirect([status,] path)

Redirect to the given `url` with optional `status` code
defaulting to 302 "Found".
Redirects to the URL derived from the specified `path`, with specified `status`, a positive integer
that corresponds to an [HTTP status code](https://www.rfc-editor.org/rfc/rfc9110#name-status-codes).
If not specified, `status` defaults to "302 "Found".

```js
res.redirect('/foo/bar');
Expand Down Expand Up @@ -338,7 +339,7 @@ the Referer (or Referrer), defaulting to `/` when missing.
res.redirect('back');
```

### res.render(view, [locals], callback)
### res.render(view [, locals] [, callback])

Render a `view` with a callback responding with
the rendered string. When an error occurs `next(err)`
Expand Down Expand Up @@ -440,7 +441,7 @@ app.get('/user/:uid/photos/:file', function (req, res) {
});
```

### res.set(field, [value])
### res.set(field [, value])

Set header `field` to `value`, or pass an object to set multiple fields at once.

Expand Down
2 changes: 1 addition & 1 deletion src/content/api/4x/api/response/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ or the referring URL, and the URL specified in the `Location` header; and redire
### res.redirect([status,] path)

Redirects to the URL derived from the specified `path`, with specified `status`, a positive integer
that corresponds to an [HTTP status code](https://www.rfc-editor.org/rfc/rfc9110#name-status-codes) .
that corresponds to an [HTTP status code](https://www.rfc-editor.org/rfc/rfc9110#name-status-codes).
If not specified, `status` defaults to "302 "Found".

```js
Expand Down
Loading