From 853e9860c7f419328a9cef65f4c58fc3b1063a21 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Fri, 26 Dec 2025 10:37:03 -0500 Subject: [PATCH 1/5] feat(v5-migration-recipe): create migration recipe for Express.js v5 addressing deprecated APIs --- codemods/v5-migration-recipe/README.md | 16 ++++++++++++ codemods/v5-migration-recipe/codemod.yaml | 25 +++++++++++++++++++ codemods/v5-migration-recipe/package.json | 19 ++++++++++++++ codemods/v5-migration-recipe/workflow.yaml | 29 ++++++++++++++++++++++ 4 files changed, 89 insertions(+) create mode 100644 codemods/v5-migration-recipe/README.md create mode 100644 codemods/v5-migration-recipe/codemod.yaml create mode 100644 codemods/v5-migration-recipe/package.json create mode 100644 codemods/v5-migration-recipe/workflow.yaml diff --git a/codemods/v5-migration-recipe/README.md b/codemods/v5-migration-recipe/README.md new file mode 100644 index 0000000..3d1ddbd --- /dev/null +++ b/codemods/v5-migration-recipe/README.md @@ -0,0 +1,16 @@ +# Migrate recipes for Express.js v5 + +This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs. + +Included transformations: + +- **Back Redirect Deprecated**: This transformation updates instances of `res.redirect('back')` and `res.location('back')` to use the recommended alternatives. Registry entry: [https://app.codemod.com/registry/expressjs/back-redirect-deprecated](https://app.codemod.com/registry/expressjs/back-redirect-deprecated). +- **Req Param**: Migrates usage of the legacy API `req.param(name)` to the current recommended alternatives. Registry entry: [https://app.codemod.com/registry/expressjs/req-param](https://app.codemod.com/registry/expressjs/req-param). +- **Pluralize Method Names**: Migrates deprecated singular request methods to their pluralized counterparts where applicable. Registry entry: [https://app.codemod.com/registry/expressjs/pluralize-method-names](https://app.codemod.com/registry/expressjs/pluralize-method-names). +- **Status Send Order**: Migrates usages of `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)`, and `res.jsonp(obj, status)` to the recommended argument ordering. Registry entry: [https://app.codemod.com/registry/expressjs/status-send-order](https://app.codemod.com/registry/expressjs/status-send-order). +- **Redirect Arg Order**: Converts `res.redirect(url, status)` calls to the recommended `res.redirect(status, url)` ordering. Registry entry: [https://app.codemod.com/registry/expressjs/redirect-arg-order](https://app.codemod.com/registry/expressjs/redirect-arg-order). +- **Camelcase Sendfile**: Replaces legacy `res.sendfile(file)` usages with the camel-cased `res.sendFile(file)` API. Registry entry: [https://app.codemod.com/registry/expressjs/camelcase-sendfile](https://app.codemod.com/registry/expressjs/camelcase-sendfile). + +## References + +- [Express.js v5 Migration Guide](https://expressjs.com/en/guide/migrating-5) diff --git a/codemods/v5-migration-recipe/codemod.yaml b/codemods/v5-migration-recipe/codemod.yaml new file mode 100644 index 0000000..b58f4b5 --- /dev/null +++ b/codemods/v5-migration-recipe/codemod.yaml @@ -0,0 +1,25 @@ +schema_version: "1.0" +name: "@expressjs/v5/migration-recipe" +version: "1.0.0" +description: This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs. +author: bjohansebas (Sebastian Beltran) +license: MIT +workflow: workflow.yaml +category: migration + +targets: + languages: + - javascript + - typescript + +keywords: + - transformation + - migration + - express + - v5 + - v4 + - legacy + +registry: + access: public + visibility: public \ No newline at end of file diff --git a/codemods/v5-migration-recipe/package.json b/codemods/v5-migration-recipe/package.json new file mode 100644 index 0000000..7663ab4 --- /dev/null +++ b/codemods/v5-migration-recipe/package.json @@ -0,0 +1,19 @@ +{ + "name": "@expressjs/v5-migration-recipe", + "private": true, + "version": "1.0.0", + "description": "This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs.", + "type": "module", + "repository": { + "type": "git", + "url": "git+https://github.com/expressjs/codemod.git", + "directory": "codemods/v5-migration-recipe", + "bugs": "https://github.com/expressjs/codemod/issues" + }, + "author": "bjohansebas (Sebastian Beltran)", + "license": "MIT", + "homepage": "https://github.com/expressjs/codemod/blob/main/codemods/v5-migration-recipe/README.md", + "devDependencies": { + "@codemod.com/jssg-types": "^1.3.1" + } +} diff --git a/codemods/v5-migration-recipe/workflow.yaml b/codemods/v5-migration-recipe/workflow.yaml new file mode 100644 index 0000000..cae1a75 --- /dev/null +++ b/codemods/v5-migration-recipe/workflow.yaml @@ -0,0 +1,29 @@ +# yaml-language-server: $schema=https://raw.githubusercontent.com/codemod-com/codemod/refs/heads/main/schemas/workflow.json + +version: "1" + +nodes: + - id: apply-transforms + name: Apply AST Transformations + type: automatic + runtime: + type: direct + steps: + - name: Migrates usage of the legacy APIs `res.redirect('back')` and `res.location('back')` to the current recommended approaches + codemod: + source: "@expressjs/back-redirect-deprecated" + - name: Migrates usage of the legacy APIs `req.param(name)` to the current recommended approaches. + codemod: + source: "@expressjs/req-param" + - name: Migrates usage of deprecated singular request methods to their pluralized versions in Express.js applications. + codemod: + source: "@expressjs/pluralize-method-names" + - name: Migrates usage of the legacy APIs `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)` and `res.jsonp(obj, status)` to the current recommended approachesç + codemod: + source: "@expressjs/status-send-order" + - name: Migrates usage of the legacy APIs `res.redirect(url, status)` to use the recommended argument order `res.redirect(status, url)`. + codemod: + source: "@expressjs/redirect-arg-order" + - name: Migrates usage of the legacy API `res.sendfile(file)` to `res.sendFile(file)` + codemod: + source: "@expressjs/camelcase-sendfile" \ No newline at end of file From ddab557a947991ba7e0f99b224b63575360cc1f0 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Fri, 26 Dec 2025 21:03:57 -0500 Subject: [PATCH 2/5] feat(v5-migration-recipe): add transformation for migrating app.del() to app.delete() --- codemods/v5-migration-recipe/README.md | 1 + codemods/v5-migration-recipe/workflow.yaml | 5 ++++- 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/codemods/v5-migration-recipe/README.md b/codemods/v5-migration-recipe/README.md index 3d1ddbd..787aa47 100644 --- a/codemods/v5-migration-recipe/README.md +++ b/codemods/v5-migration-recipe/README.md @@ -10,6 +10,7 @@ Included transformations: - **Status Send Order**: Migrates usages of `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)`, and `res.jsonp(obj, status)` to the recommended argument ordering. Registry entry: [https://app.codemod.com/registry/expressjs/status-send-order](https://app.codemod.com/registry/expressjs/status-send-order). - **Redirect Arg Order**: Converts `res.redirect(url, status)` calls to the recommended `res.redirect(status, url)` ordering. Registry entry: [https://app.codemod.com/registry/expressjs/redirect-arg-order](https://app.codemod.com/registry/expressjs/redirect-arg-order). - **Camelcase Sendfile**: Replaces legacy `res.sendfile(file)` usages with the camel-cased `res.sendFile(file)` API. Registry entry: [https://app.codemod.com/registry/expressjs/camelcase-sendfile](https://app.codemod.com/registry/expressjs/camelcase-sendfile). +- **Route Del to Delete**: Migrates usage of the legacy APIs `app.del()` to `app.delete()`. Registry entry: [https://app.codemod.com/registry/expressjs/route-del-to-delete](https://app.codemod.com/registry/expressjs/route-del-to-delete). ## References diff --git a/codemods/v5-migration-recipe/workflow.yaml b/codemods/v5-migration-recipe/workflow.yaml index cae1a75..cd4a485 100644 --- a/codemods/v5-migration-recipe/workflow.yaml +++ b/codemods/v5-migration-recipe/workflow.yaml @@ -26,4 +26,7 @@ nodes: source: "@expressjs/redirect-arg-order" - name: Migrates usage of the legacy API `res.sendfile(file)` to `res.sendFile(file)` codemod: - source: "@expressjs/camelcase-sendfile" \ No newline at end of file + source: "@expressjs/camelcase-sendfile" + - name: Migrates usage of the legacy APIs `app.del()` to `app.delete()` + codemod: + source: "@expressjs/route-del-to-delete" \ No newline at end of file From 6113ad3de3a3996d145ecf8727e19c8810cfa17c Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Tue, 6 Jan 2026 18:09:44 -0500 Subject: [PATCH 3/5] Update codemods/v5-migration-recipe/workflow.yaml Co-authored-by: Mohamad Mohebifar Signed-off-by: Sebastian Beltran --- codemods/v5-migration-recipe/workflow.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codemods/v5-migration-recipe/workflow.yaml b/codemods/v5-migration-recipe/workflow.yaml index cd4a485..9c98559 100644 --- a/codemods/v5-migration-recipe/workflow.yaml +++ b/codemods/v5-migration-recipe/workflow.yaml @@ -18,7 +18,7 @@ nodes: - name: Migrates usage of deprecated singular request methods to their pluralized versions in Express.js applications. codemod: source: "@expressjs/pluralize-method-names" - - name: Migrates usage of the legacy APIs `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)` and `res.jsonp(obj, status)` to the current recommended approachesç + - name: Migrates usage of the legacy APIs `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)` and `res.jsonp(obj, status)` to the current recommended approaches codemod: source: "@expressjs/status-send-order" - name: Migrates usage of the legacy APIs `res.redirect(url, status)` to use the recommended argument order `res.redirect(status, url)`. From 95ddd65101d678f4bd1507971e5ec750e775759b Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Tue, 13 Jan 2026 10:38:50 -0500 Subject: [PATCH 4/5] feat(v5-migration-recipe): update repository link and add metadata to package-lock --- codemods/v5-migration-recipe/codemod.yaml | 1 + package-lock.json | 12 ++++++++++++ 2 files changed, 13 insertions(+) diff --git a/codemods/v5-migration-recipe/codemod.yaml b/codemods/v5-migration-recipe/codemod.yaml index b58f4b5..418dc9e 100644 --- a/codemods/v5-migration-recipe/codemod.yaml +++ b/codemods/v5-migration-recipe/codemod.yaml @@ -5,6 +5,7 @@ description: This codemod migration recipe helps you update your Express.js v4 a author: bjohansebas (Sebastian Beltran) license: MIT workflow: workflow.yaml +repository: "https://github.com/expressjs/codemod/tree/HEAD/codemods/v5-migration-recipe" category: migration targets: diff --git a/package-lock.json b/package-lock.json index f9dd8a2..fc318a3 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,6 +113,14 @@ "@codemod.com/jssg-types": "^1.3.1" } }, + "codemods/v5-migration-recipe": { + "name": "@expressjs/v5-migration-recipe", + "version": "1.0.0", + "license": "MIT", + "devDependencies": { + "@codemod.com/jssg-types": "^1.3.1" + } + }, "node_modules/@ampproject/remapping": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/@ampproject/remapping/-/remapping-2.3.0.tgz", @@ -1098,6 +1106,10 @@ "resolved": "codemods/status-send-order", "link": true }, + "node_modules/@expressjs/v5-migration-recipe": { + "resolved": "codemods/v5-migration-recipe", + "link": true + }, "node_modules/@istanbuljs/load-nyc-config": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", From 16bdb9eb8d08c4512a3d0af8168021992ef26606 Mon Sep 17 00:00:00 2001 From: Sebastian Beltran Date: Tue, 13 Jan 2026 10:52:00 -0500 Subject: [PATCH 5/5] fix(v5-migration-recipe): update registry source for req.param migration to explicit-request-params --- codemods/v5-migration-recipe/README.md | 14 +++++++------- codemods/v5-migration-recipe/workflow.yaml | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/codemods/v5-migration-recipe/README.md b/codemods/v5-migration-recipe/README.md index 787aa47..3b1abc1 100644 --- a/codemods/v5-migration-recipe/README.md +++ b/codemods/v5-migration-recipe/README.md @@ -4,13 +4,13 @@ This codemod migration recipe helps you update your Express.js v4 applications t Included transformations: -- **Back Redirect Deprecated**: This transformation updates instances of `res.redirect('back')` and `res.location('back')` to use the recommended alternatives. Registry entry: [https://app.codemod.com/registry/expressjs/back-redirect-deprecated](https://app.codemod.com/registry/expressjs/back-redirect-deprecated). -- **Req Param**: Migrates usage of the legacy API `req.param(name)` to the current recommended alternatives. Registry entry: [https://app.codemod.com/registry/expressjs/req-param](https://app.codemod.com/registry/expressjs/req-param). -- **Pluralize Method Names**: Migrates deprecated singular request methods to their pluralized counterparts where applicable. Registry entry: [https://app.codemod.com/registry/expressjs/pluralize-method-names](https://app.codemod.com/registry/expressjs/pluralize-method-names). -- **Status Send Order**: Migrates usages of `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)`, and `res.jsonp(obj, status)` to the recommended argument ordering. Registry entry: [https://app.codemod.com/registry/expressjs/status-send-order](https://app.codemod.com/registry/expressjs/status-send-order). -- **Redirect Arg Order**: Converts `res.redirect(url, status)` calls to the recommended `res.redirect(status, url)` ordering. Registry entry: [https://app.codemod.com/registry/expressjs/redirect-arg-order](https://app.codemod.com/registry/expressjs/redirect-arg-order). -- **Camelcase Sendfile**: Replaces legacy `res.sendfile(file)` usages with the camel-cased `res.sendFile(file)` API. Registry entry: [https://app.codemod.com/registry/expressjs/camelcase-sendfile](https://app.codemod.com/registry/expressjs/camelcase-sendfile). -- **Route Del to Delete**: Migrates usage of the legacy APIs `app.del()` to `app.delete()`. Registry entry: [https://app.codemod.com/registry/expressjs/route-del-to-delete](https://app.codemod.com/registry/expressjs/route-del-to-delete). +- **Back Redirect Deprecated**: This transformation updates instances of `res.redirect('back')` and `res.location('back')` to use the recommended alternatives. Registry entry: [https://app.codemod.com/registry/@expressjs/back-redirect-deprecated](https://app.codemod.com/registry/@expressjs/back-redirect-deprecated). +- **Explicit Request Params**: Migrates usage of the legacy API `req.param(name)` to the current recommended alternatives. Registry entry: [https://app.codemod.com/registry/@expressjs/explicit-request-params](https://app.codemod.com/registry/@expressjs/explicit-request-params). +- **Pluralize Method Names**: Migrates deprecated singular request methods to their pluralized counterparts where applicable. Registry entry: [https://app.codemod.com/registry/@expressjs/pluralize-method-names](https://app.codemod.com/registry/@expressjs/pluralize-method-names). +- **Status Send Order**: Migrates usages of `res.send(status)`, `res.send(obj, status)`, `res.json(obj, status)`, and `res.jsonp(obj, status)` to the recommended argument ordering. Registry entry: [https://app.codemod.com/registry/@expressjs/status-send-order](https://app.codemod.com/registry/@expressjs/status-send-order). +- **Redirect Arg Order**: Converts `res.redirect(url, status)` calls to the recommended `res.redirect(status, url)` ordering. Registry entry: [https://app.codemod.com/registry/@expressjs/redirect-arg-order](https://app.codemod.com/registry/@expressjs/redirect-arg-order). +- **Camelcase Sendfile**: Replaces legacy `res.sendfile(file)` usages with the camel-cased `res.sendFile(file)` API. Registry entry: [https://app.codemod.com/registry/@expressjs/camelcase-sendfile](https://app.codemod.com/registry/@expressjs/camelcase-sendfile). +- **Route Del to Delete**: Migrates usage of the legacy APIs `app.del()` to `app.delete()`. Registry entry: [https://app.codemod.com/registry/@expressjs/route-del-to-delete](https://app.codemod.com/registry/@expressjs/route-del-to-delete). ## References diff --git a/codemods/v5-migration-recipe/workflow.yaml b/codemods/v5-migration-recipe/workflow.yaml index 9c98559..77ae2fd 100644 --- a/codemods/v5-migration-recipe/workflow.yaml +++ b/codemods/v5-migration-recipe/workflow.yaml @@ -14,7 +14,7 @@ nodes: source: "@expressjs/back-redirect-deprecated" - name: Migrates usage of the legacy APIs `req.param(name)` to the current recommended approaches. codemod: - source: "@expressjs/req-param" + source: "@expressjs/explicit-request-params" - name: Migrates usage of deprecated singular request methods to their pluralized versions in Express.js applications. codemod: source: "@expressjs/pluralize-method-names"