You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(status-send-order): migrate logic of v4-deprecate-signatures to ast-grep (#97)
* feat(status-send-order): migrate logic of v4-deprecate-signatures to ast-grep
* fix(package): update repository directory and homepage for status-send-order
* Update codemods/status-send-order/codemod.yaml
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
* refactor(workflow): simplify early return conditions for nodes and edits
---------
Signed-off-by: Sebastian Beltran <bjohansebas@gmail.com>
Migrates usage of the legacy APIs `res.send(obj, status)`, `res.json(obj, status)`, and `res.jsonp(obj, status)` to use the recommended approach of specifying the status code
4
+
using the `res.status(status).send(obj)`, `res.status(status).json(obj)`, and
5
+
`res.status(status).jsonp(obj)` methods respectively. The older APIs that allowed
6
+
specifying the status code as a second argument have been deprecated.
7
+
8
+
## Example
9
+
10
+
### Migrating `res.send(obj, status)`
11
+
12
+
The migration involves replacing instances of `res.send(obj, status)` with `res.status(status).send(obj)`.
13
+
14
+
```diff
15
+
app.get('/some-route', (req, res) => {
16
+
// Some logic here
17
+
- res.send(obj, status);
18
+
+ res.status(status).send(obj);
19
+
});
20
+
```
21
+
22
+
### Migrating `res.json(obj, status)`
23
+
24
+
The migration involves replacing instances of `res.json(obj, status)` with `res.status(status).json(obj)`.
25
+
26
+
```diff
27
+
app.get('/some-route', (req, res) => {
28
+
// Some logic here
29
+
- res.json(obj, status);
30
+
+ res.status(status).json(obj);
31
+
});
32
+
```
33
+
### Migrating `res.jsonp(obj, status)`
34
+
35
+
The migration involves replacing instances of `res.jsonp(obj, status)` with `res.status(status).jsonp(obj)`.
36
+
37
+
```diff
38
+
app.get('/some-route', (req, res) => {
39
+
// Some logic here
40
+
- res.jsonp(obj, status);
41
+
+ res.status(status).jsonp(obj);
42
+
});
43
+
```
44
+
45
+
### Migrating `res.send(status)`
46
+
47
+
The migration involves replacing instances of `res.send(status)` with `res.sendStatus(status)`.
48
+
49
+
```diff
50
+
app.get('/some-route', (req, res) => {
51
+
// Some logic here
52
+
- res.send(status);
53
+
+ res.sendStatus(status);
54
+
});
55
+
```
56
+
57
+
## References
58
+
59
+
-[Migration of res.send(status)](https://expressjs.com/en/guide/migrating-5.html#res.send.status)
60
+
-[Migration of res.send(obj, status)](https://expressjs.com/en/guide/migrating-5.html#res.send.body)
61
+
-[Migration of res.json(obj, status)](https://expressjs.com/en/guide/migrating-5.html#res.json)
62
+
-[Migration of res.jsonp(obj, status)](https://expressjs.com/en/guide/migrating-5.html#res.jsonp)
description: 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
"description": "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",
6
+
"type": "module",
7
+
"scripts": {
8
+
"test": "npx codemod jssg test -l typescript ./src/workflow.ts ./"
0 commit comments