Skip to content

Commit add40f7

Browse files
feat(v5-migration-recipe): create migration recipe for Express.js v5 (#101)
* feat(v5-migration-recipe): create migration recipe for Express.js v5 addressing deprecated APIs * feat(v5-migration-recipe): add transformation for migrating app.del() to app.delete() * Update codemods/v5-migration-recipe/workflow.yaml Co-authored-by: Mohamad Mohebifar <mohebifar@users.noreply.github.com> Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> * feat(v5-migration-recipe): update repository link and add metadata to package-lock * fix(v5-migration-recipe): update registry source for req.param migration to explicit-request-params --------- Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com> Co-authored-by: Mohamad Mohebifar <mohebifar@users.noreply.github.com>
1 parent 5464214 commit add40f7

File tree

5 files changed

+106
-0
lines changed

5 files changed

+106
-0
lines changed
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# Migrate recipes for Express.js v5
2+
3+
This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs.
4+
5+
Included transformations:
6+
7+
- **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).
8+
- **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).
9+
- **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).
10+
- **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).
11+
- **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).
12+
- **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).
13+
- **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).
14+
15+
## References
16+
17+
- [Express.js v5 Migration Guide](https://expressjs.com/en/guide/migrating-5)
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
schema_version: "1.0"
2+
name: "@expressjs/v5/migration-recipe"
3+
version: "1.0.0"
4+
description: This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs.
5+
author: bjohansebas (Sebastian Beltran)
6+
license: MIT
7+
workflow: workflow.yaml
8+
repository: "https://github.com/expressjs/codemod/tree/HEAD/codemods/v5-migration-recipe"
9+
category: migration
10+
11+
targets:
12+
languages:
13+
- javascript
14+
- typescript
15+
16+
keywords:
17+
- transformation
18+
- migration
19+
- express
20+
- v5
21+
- v4
22+
- legacy
23+
24+
registry:
25+
access: public
26+
visibility: public
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
{
2+
"name": "@expressjs/v5-migration-recipe",
3+
"private": true,
4+
"version": "1.0.0",
5+
"description": "This codemod migration recipe helps you update your Express.js v4 applications to be compatible with Express.js v5 by addressing deprecated APIs.",
6+
"type": "module",
7+
"repository": {
8+
"type": "git",
9+
"url": "git+https://github.com/expressjs/codemod.git",
10+
"directory": "codemods/v5-migration-recipe",
11+
"bugs": "https://github.com/expressjs/codemod/issues"
12+
},
13+
"author": "bjohansebas (Sebastian Beltran)",
14+
"license": "MIT",
15+
"homepage": "https://github.com/expressjs/codemod/blob/main/codemods/v5-migration-recipe/README.md",
16+
"devDependencies": {
17+
"@codemod.com/jssg-types": "^1.3.1"
18+
}
19+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/codemod-com/codemod/refs/heads/main/schemas/workflow.json
2+
3+
version: "1"
4+
5+
nodes:
6+
- id: apply-transforms
7+
name: Apply AST Transformations
8+
type: automatic
9+
runtime:
10+
type: direct
11+
steps:
12+
- name: Migrates usage of the legacy APIs `res.redirect('back')` and `res.location('back')` to the current recommended approaches
13+
codemod:
14+
source: "@expressjs/back-redirect-deprecated"
15+
- name: Migrates usage of the legacy APIs `req.param(name)` to the current recommended approaches.
16+
codemod:
17+
source: "@expressjs/explicit-request-params"
18+
- name: Migrates usage of deprecated singular request methods to their pluralized versions in Express.js applications.
19+
codemod:
20+
source: "@expressjs/pluralize-method-names"
21+
- 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
22+
codemod:
23+
source: "@expressjs/status-send-order"
24+
- name: Migrates usage of the legacy APIs `res.redirect(url, status)` to use the recommended argument order `res.redirect(status, url)`.
25+
codemod:
26+
source: "@expressjs/redirect-arg-order"
27+
- name: Migrates usage of the legacy API `res.sendfile(file)` to `res.sendFile(file)`
28+
codemod:
29+
source: "@expressjs/camelcase-sendfile"
30+
- name: Migrates usage of the legacy APIs `app.del()` to `app.delete()`
31+
codemod:
32+
source: "@expressjs/route-del-to-delete"

package-lock.json

Lines changed: 12 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)