From 55b0e96d9dbf87561ea8b07959d6ea56b2bf3011 Mon Sep 17 00:00:00 2001 From: krzysdz Date: Mon, 1 Jun 2026 03:01:37 +0200 Subject: [PATCH] Fix broken sidebar menu links One broken menu item in 4.x - `/en/4x/api/request#reqparamname`: separated 4.x and 3.x cases, as 4.x allows a default value (at least according to docs content) Broken menu items in 3.x - `/en/3x/api/application#appallpath-callback--callback-`: moved optional parameter to last pos to match 4.x and 5.x header - `/en/3x/api/application#applistenport-host-backlog-callback`: separated 3.x from 4.x/5.x - `/en/3x/api/application#apprenderview-locals-callback`: renamed `options` to locals (see https://github.com/expressjs/expressjs.com/commit/9162fa120c6b14b640a9746eaebe743f1bf63203) - `/en/3x/api/application#appusepath-callback--callback`: separated 3.x from 4.x/5.x as according to API docs 3.x allows only one function per .use call - `/en/3x/api/request#reqheaderfield`: merged with 4.x/5.x `req.get()` menu header, because it has been this way in old docs and I could not find `req.header()` outside `req.get()` description: https://github.com/expressjs/expressjs.com/blob/old-website/_includes/api/en/3x/req-header.md, https://github.com/expressjs/expressjs.com/blob/9e957d4e2c46a9042e1b4bcf9fcee686e3db5a71/en/api/req-header.jade - `/en/3x/api/response#resclearcookiename--options`: used header from 4.x/5.x (comma moved into []) - `/en/3x/api/response#rescookiename-value--options`: used header from 4.x/5.x (comma moved into []) - `/en/3x/api/response#resdownloadpath--filename--options--fn`: separated 3.x from 4.x/5.x, because signature is different - `/en/3x/api/response#resjsonbody`: separated 3.x from 4.x/5.x, because 3.x allows optional status - `/en/3x/api/response#resjsonpbody`: separated 3.x from 4.x/5.x, because 3.x allows optional status - `/en/3x/api/response#reslocationpath`: renamed 3.x to match 4.x/5.x header - `/en/3x/api/response#resredirectstatus-path`: renamed 3.x to match 4.x/5.x header and updated docs content to match (copied from 4.x) - `/en/3x/api/response#resrenderview--locals--callback`: changed header to match 4.x (callback is optional); the 3.x docs are not great and somewhat differ from JSDoc (https://github.com/expressjs/express/blob/cb59086305367d9fcd7d63b53cfca1a3e4ef77d7/lib/response.js#L808-L846) - `/en/3x/api/response#ressendbody`: separated 3.x from 4.x/5.x, because 3.x allows optional status - `/en/3x/api/response#ressetfield--value`: used header from 4.x/5.x (comma moved into []) --- src/config/menu/api.ts | 56 ++++++++++++++++---- src/content/api/3x/api/application/index.mdx | 4 +- src/content/api/3x/api/response/index.mdx | 19 +++---- src/content/api/4x/api/response/index.mdx | 2 +- 4 files changed, 59 insertions(+), 22 deletions(-) diff --git a/src/config/menu/api.ts b/src/config/menu/api.ts index 1afb9a6652..c72e50fd1e 100644 --- a/src/config/menu/api.ts +++ b/src/config/menu/api.ts @@ -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-', @@ -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()', @@ -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', @@ -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', @@ -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()', diff --git a/src/content/api/3x/api/application/index.mdx b/src/content/api/3x/api/application/index.mdx index 0f7e469613..e3282322e2 100644 --- a/src/content/api/3x/api/application/index.mdx +++ b/src/content/api/3x/api/application/index.mdx @@ -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. @@ -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()`, diff --git a/src/content/api/3x/api/response/index.mdx b/src/content/api/3x/api/response/index.mdx index f488de7412..9baf5ab055 100644 --- a/src/content/api/3x/api/response/index.mdx +++ b/src/content/api/3x/api/response/index.mdx @@ -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 "/". @@ -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 "/". @@ -264,7 +264,7 @@ Link: rel="next", rel="last" ``` -### res.location() +### res.location(path) Set the location header. @@ -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 @@ -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'); @@ -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)` @@ -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. diff --git a/src/content/api/4x/api/response/index.mdx b/src/content/api/4x/api/response/index.mdx index fa9559dab4..b0e11a207b 100644 --- a/src/content/api/4x/api/response/index.mdx +++ b/src/content/api/4x/api/response/index.mdx @@ -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