Skip to content

Commit 4fb1e92

Browse files
kjugibjohansebas
andauthored
feat: add missing transforms #10 (#3)
* add draft for missing transforms * add some test * base idea to solve single param .send method * move out recursiveParent to utils * convert send to deprecated-signatures * fix bug in send output file * rename deprecated-signatures to v3-deprecated-signatures, cover json and jsonp cases, unify logic for 2 arguments with status and body * add valid syntax cases for send method and add test cases * split json and jsonp tests and add test cases with checking still supported syntax * add vscode config to gitignore * change deprecated-signatures prefix to v4 * update transform config for v4-deprecated-signatures --------- Co-authored-by: Filip Kudła <[email protected]> Co-authored-by: Sebastian Beltran <[email protected]>
1 parent e64c5d1 commit 4fb1e92

File tree

13 files changed

+503
-23
lines changed

13 files changed

+503
-23
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,7 @@ yarn-error.log*
2525

2626
*.d.ts
2727
*.js
28-
*.js.map
28+
*.js.map
29+
30+
# VSCode
31+
.vscode

config.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,9 @@ export const TRANSFORM_OPTIONS = [
99
value: 'pluralized-methods',
1010
version: '5.0.0',
1111
},
12-
//{ description: 'Transform the deprecated signatures in Express v4', value: 'signature-deprecated', version: '5.0.0' },
12+
{
13+
description: 'Transform the deprecated signatures in Express v4',
14+
value: 'v4-deprecated-signatures',
15+
version: '5.0.0'
16+
},
1317
]
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import { testSpecBuilder } from './util'
2+
3+
testSpecBuilder('v4-deprecated-signatures')
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/json", function (req, res) {
6+
res.json({ user: "Username", isValid: true }, 200);
7+
});
8+
9+
app.get("/json", function (req, response) {
10+
response.json({ user: "Username", isValid: true }, 200);
11+
});
12+
13+
app.get("/json", (req, res) => {
14+
res.json({ user: "Username", isValid: true }, 200);
15+
});
16+
17+
app.get("/json", (req, response) => {
18+
response.json({ user: "Username", isValid: true }, 200);
19+
});
20+
21+
app.get("/json", function (req, res) {
22+
res.json({}, 200);
23+
});
24+
25+
app.get("/json", function (req, response) {
26+
response.json({}, 200);
27+
});
28+
29+
app.get("/json", (req, res) => {
30+
res.json({}, 200);
31+
});
32+
33+
app.get("/json", (req, response) => {
34+
response.json({}, 200);
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/json", function (req, res) {
39+
res.json(null)
40+
res.json({ user: 'tobi' })
41+
})
42+
43+
app.get("/json", function (req, response) {
44+
response.json(null)
45+
response.json({ user: 'tobi' })
46+
})
47+
48+
app.get("/json", function (req, res) {
49+
res.json(null)
50+
res.json({ user: 'tobi' })
51+
})
52+
53+
app.get("/json", function (req, response) {
54+
response.json(null)
55+
response.json({ user: 'tobi' })
56+
})
57+
// Still valid syntax -- END
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/json", function (req, res) {
6+
res.status(200).json({ user: "Username", isValid: true });
7+
});
8+
9+
app.get("/json", function (req, response) {
10+
response.status(200).json({ user: "Username", isValid: true });
11+
});
12+
13+
app.get("/json", (req, res) => {
14+
res.status(200).json({ user: "Username", isValid: true });
15+
});
16+
17+
app.get("/json", (req, response) => {
18+
response.status(200).json({ user: "Username", isValid: true });
19+
});
20+
21+
app.get("/json", function (req, res) {
22+
res.status(200).json({});
23+
});
24+
25+
app.get("/json", function (req, response) {
26+
response.status(200).json({});
27+
});
28+
29+
app.get("/json", (req, res) => {
30+
res.status(200).json({});
31+
});
32+
33+
app.get("/json", (req, response) => {
34+
response.status(200).json({});
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/json", function (req, res) {
39+
res.json(null)
40+
res.json({ user: 'tobi' })
41+
})
42+
43+
app.get("/json", function (req, response) {
44+
response.json(null)
45+
response.json({ user: 'tobi' })
46+
})
47+
48+
app.get("/json", function (req, res) {
49+
res.json(null)
50+
res.json({ user: 'tobi' })
51+
})
52+
53+
app.get("/json", function (req, response) {
54+
response.json(null)
55+
response.json({ user: 'tobi' })
56+
})
57+
// Still valid syntax -- END
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/jsonp", function (req, res) {
6+
res.jsonp({ user: "Username", isValid: true }, 200);
7+
});
8+
9+
app.get("/jsonp", function (req, response) {
10+
response.jsonp({ user: "Username", isValid: true }, 200);
11+
});
12+
13+
app.get("/jsonp", (req, res) => {
14+
res.jsonp({ user: "Username", isValid: true }, 200);
15+
});
16+
17+
app.get("/jsonp", (req, response) => {
18+
response.jsonp({ user: "Username", isValid: true }, 200);
19+
});
20+
21+
app.get("/jsonp", function (req, res) {
22+
res.jsonp({}, 200);
23+
});
24+
25+
app.get("/jsonp", function (req, response) {
26+
response.jsonp({}, 200);
27+
});
28+
29+
app.get("/jsonp", (req, res) => {
30+
res.jsonp({}, 200)
31+
});
32+
33+
app.get("/jsonp", (req, response) => {
34+
response.jsonp({}, 200)
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/jsonp", function (req, res) {
39+
res.jsonp(null)
40+
res.jsonp({ user: 'tobi' })
41+
})
42+
43+
app.get("/jsonp", function (req, response) {
44+
response.jsonp(null)
45+
response.jsonp({ user: 'tobi' })
46+
})
47+
48+
app.get("/jsonp", function (req, res) {
49+
res.jsonp(null)
50+
res.jsonp({ user: 'tobi' })
51+
})
52+
53+
app.get("/jsonp", function (req, response) {
54+
response.jsonp(null)
55+
response.jsonp({ user: 'tobi' })
56+
})
57+
// Still valid syntax -- END
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/jsonp", function (req, res) {
6+
res.status(200).jsonp({ user: "Username", isValid: true });
7+
});
8+
9+
app.get("/jsonp", function (req, response) {
10+
response.status(200).jsonp({ user: "Username", isValid: true });
11+
});
12+
13+
app.get("/jsonp", (req, res) => {
14+
res.status(200).jsonp({ user: "Username", isValid: true });
15+
});
16+
17+
app.get("/jsonp", (req, response) => {
18+
response.status(200).jsonp({ user: "Username", isValid: true });
19+
});
20+
21+
app.get("/jsonp", function (req, res) {
22+
res.status(200).jsonp({});
23+
});
24+
25+
app.get("/jsonp", function (req, response) {
26+
response.status(200).jsonp({});
27+
});
28+
29+
app.get("/jsonp", (req, res) => {
30+
res.status(200).jsonp({})
31+
});
32+
33+
app.get("/jsonp", (req, response) => {
34+
response.status(200).jsonp({})
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/jsonp", function (req, res) {
39+
res.jsonp(null)
40+
res.jsonp({ user: 'tobi' })
41+
})
42+
43+
app.get("/jsonp", function (req, response) {
44+
response.jsonp(null)
45+
response.jsonp({ user: 'tobi' })
46+
})
47+
48+
app.get("/jsonp", function (req, res) {
49+
res.jsonp(null)
50+
res.jsonp({ user: 'tobi' })
51+
})
52+
53+
app.get("/jsonp", function (req, response) {
54+
response.jsonp(null)
55+
response.jsonp({ user: 'tobi' })
56+
})
57+
// Still valid syntax -- END
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/send", function (req, res) {
6+
res.send(200, { hello: "world" });
7+
});
8+
9+
app.get("/send", function (req, response) {
10+
response.send(200, "Hello World");
11+
});
12+
13+
app.get("/send", function (req, res) {
14+
res.send(200);
15+
});
16+
17+
app.get("/send", function (req, res) {
18+
res.send(200, true);
19+
});
20+
21+
app.get("/send", (req, res) => {
22+
res.send(200, { hello: "world" });
23+
});
24+
25+
app.get("/send", (req, res) => {
26+
res.send(200);
27+
});
28+
29+
app.get("/send", (req, response) => {
30+
response.send(200);
31+
});
32+
33+
app.get("/send", (req, response) => {
34+
response.send(200, true);
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/send", function (req, res) {
39+
res.send(Buffer.from('whoop'));
40+
res.send({ some: 'json' });
41+
res.send('<p>some html</p>');
42+
});
43+
44+
app.get("/send", function (req, response) {
45+
response.send(Buffer.from('whoop'));
46+
response.send({ some: 'json' });
47+
response.send('<p>some html</p>');
48+
});
49+
50+
app.get("/send", (req, response) => {
51+
response.send(Buffer.from('whoop'));
52+
response.send({ some: 'json' });
53+
response.send('<p>some html</p>');
54+
});
55+
56+
app.get("/send", (req, res) => {
57+
res.send(Buffer.from('whoop'));
58+
res.send({ some: 'json' });
59+
res.send('<p>some html</p>');
60+
});
61+
// Still valid syntax -- END
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import express from "express";
2+
3+
const app = express();
4+
5+
app.get("/send", function (req, res) {
6+
res.status(200).send({ hello: "world" });
7+
});
8+
9+
app.get("/send", function (req, response) {
10+
response.status(200).send("Hello World");
11+
});
12+
13+
app.get("/send", function (req, res) {
14+
res.sendStatus(200);
15+
});
16+
17+
app.get("/send", function (req, res) {
18+
res.status(200).send(true);
19+
});
20+
21+
app.get("/send", (req, res) => {
22+
res.status(200).send({ hello: "world" });
23+
});
24+
25+
app.get("/send", (req, res) => {
26+
res.sendStatus(200);
27+
});
28+
29+
app.get("/send", (req, response) => {
30+
response.sendStatus(200);
31+
});
32+
33+
app.get("/send", (req, response) => {
34+
response.status(200).send(true);
35+
});
36+
37+
// Still valid syntax -- START
38+
app.get("/send", function (req, res) {
39+
res.send(Buffer.from('whoop'));
40+
res.send({ some: 'json' });
41+
res.send('<p>some html</p>');
42+
});
43+
44+
app.get("/send", function (req, response) {
45+
response.send(Buffer.from('whoop'));
46+
response.send({ some: 'json' });
47+
response.send('<p>some html</p>');
48+
});
49+
50+
app.get("/send", (req, response) => {
51+
response.send(Buffer.from('whoop'));
52+
response.send({ some: 'json' });
53+
response.send('<p>some html</p>');
54+
});
55+
56+
app.get("/send", (req, res) => {
57+
res.send(Buffer.from('whoop'));
58+
res.send({ some: 'json' });
59+
res.send('<p>some html</p>');
60+
});
61+
// Still valid syntax -- END

0 commit comments

Comments
 (0)