-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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]>
- Loading branch information
1 parent
e64c5d1
commit 4fb1e92
Showing
13 changed files
with
503 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,7 @@ yarn-error.log* | |
|
||
*.d.ts | ||
*.js | ||
*.js.map | ||
*.js.map | ||
|
||
# VSCode | ||
.vscode |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import { testSpecBuilder } from './util' | ||
|
||
testSpecBuilder('v4-deprecated-signatures') |
57 changes: 57 additions & 0 deletions
57
transforms/__testfixtures__/v4-deprecated-signatures/json.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/json", function (req, res) { | ||
res.json({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/json", function (req, response) { | ||
response.json({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/json", (req, res) => { | ||
res.json({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/json", (req, response) => { | ||
response.json({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/json", function (req, res) { | ||
res.json({}, 200); | ||
}); | ||
|
||
app.get("/json", function (req, response) { | ||
response.json({}, 200); | ||
}); | ||
|
||
app.get("/json", (req, res) => { | ||
res.json({}, 200); | ||
}); | ||
|
||
app.get("/json", (req, response) => { | ||
response.json({}, 200); | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/json", function (req, res) { | ||
res.json(null) | ||
res.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, response) { | ||
response.json(null) | ||
response.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, res) { | ||
res.json(null) | ||
res.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, response) { | ||
response.json(null) | ||
response.json({ user: 'tobi' }) | ||
}) | ||
// Still valid syntax -- END |
57 changes: 57 additions & 0 deletions
57
transforms/__testfixtures__/v4-deprecated-signatures/json.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/json", function (req, res) { | ||
res.status(200).json({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/json", function (req, response) { | ||
response.status(200).json({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/json", (req, res) => { | ||
res.status(200).json({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/json", (req, response) => { | ||
response.status(200).json({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/json", function (req, res) { | ||
res.status(200).json({}); | ||
}); | ||
|
||
app.get("/json", function (req, response) { | ||
response.status(200).json({}); | ||
}); | ||
|
||
app.get("/json", (req, res) => { | ||
res.status(200).json({}); | ||
}); | ||
|
||
app.get("/json", (req, response) => { | ||
response.status(200).json({}); | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/json", function (req, res) { | ||
res.json(null) | ||
res.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, response) { | ||
response.json(null) | ||
response.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, res) { | ||
res.json(null) | ||
res.json({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/json", function (req, response) { | ||
response.json(null) | ||
response.json({ user: 'tobi' }) | ||
}) | ||
// Still valid syntax -- END |
57 changes: 57 additions & 0 deletions
57
transforms/__testfixtures__/v4-deprecated-signatures/jsonp.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.jsonp({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/jsonp", (req, res) => { | ||
res.jsonp({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/jsonp", (req, response) => { | ||
response.jsonp({ user: "Username", isValid: true }, 200); | ||
}); | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.jsonp({}, 200); | ||
}); | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp({}, 200); | ||
}); | ||
|
||
app.get("/jsonp", (req, res) => { | ||
res.jsonp({}, 200) | ||
}); | ||
|
||
app.get("/jsonp", (req, response) => { | ||
response.jsonp({}, 200) | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/jsonp", function (req, res) { | ||
res.jsonp(null) | ||
res.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp(null) | ||
response.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.jsonp(null) | ||
res.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp(null) | ||
response.jsonp({ user: 'tobi' }) | ||
}) | ||
// Still valid syntax -- END |
57 changes: 57 additions & 0 deletions
57
transforms/__testfixtures__/v4-deprecated-signatures/jsonp.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.status(200).jsonp({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.status(200).jsonp({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/jsonp", (req, res) => { | ||
res.status(200).jsonp({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/jsonp", (req, response) => { | ||
response.status(200).jsonp({ user: "Username", isValid: true }); | ||
}); | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.status(200).jsonp({}); | ||
}); | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.status(200).jsonp({}); | ||
}); | ||
|
||
app.get("/jsonp", (req, res) => { | ||
res.status(200).jsonp({}) | ||
}); | ||
|
||
app.get("/jsonp", (req, response) => { | ||
response.status(200).jsonp({}) | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/jsonp", function (req, res) { | ||
res.jsonp(null) | ||
res.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp(null) | ||
response.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, res) { | ||
res.jsonp(null) | ||
res.jsonp({ user: 'tobi' }) | ||
}) | ||
|
||
app.get("/jsonp", function (req, response) { | ||
response.jsonp(null) | ||
response.jsonp({ user: 'tobi' }) | ||
}) | ||
// Still valid syntax -- END |
61 changes: 61 additions & 0 deletions
61
transforms/__testfixtures__/v4-deprecated-signatures/send.input.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/send", function (req, res) { | ||
res.send(200, { hello: "world" }); | ||
}); | ||
|
||
app.get("/send", function (req, response) { | ||
response.send(200, "Hello World"); | ||
}); | ||
|
||
app.get("/send", function (req, res) { | ||
res.send(200); | ||
}); | ||
|
||
app.get("/send", function (req, res) { | ||
res.send(200, true); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.send(200, { hello: "world" }); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.send(200); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.send(200); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.send(200, true); | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/send", function (req, res) { | ||
res.send(Buffer.from('whoop')); | ||
res.send({ some: 'json' }); | ||
res.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", function (req, response) { | ||
response.send(Buffer.from('whoop')); | ||
response.send({ some: 'json' }); | ||
response.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.send(Buffer.from('whoop')); | ||
response.send({ some: 'json' }); | ||
response.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.send(Buffer.from('whoop')); | ||
res.send({ some: 'json' }); | ||
res.send('<p>some html</p>'); | ||
}); | ||
// Still valid syntax -- END |
61 changes: 61 additions & 0 deletions
61
transforms/__testfixtures__/v4-deprecated-signatures/send.output.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import express from "express"; | ||
|
||
const app = express(); | ||
|
||
app.get("/send", function (req, res) { | ||
res.status(200).send({ hello: "world" }); | ||
}); | ||
|
||
app.get("/send", function (req, response) { | ||
response.status(200).send("Hello World"); | ||
}); | ||
|
||
app.get("/send", function (req, res) { | ||
res.sendStatus(200); | ||
}); | ||
|
||
app.get("/send", function (req, res) { | ||
res.status(200).send(true); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.status(200).send({ hello: "world" }); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.sendStatus(200); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.sendStatus(200); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.status(200).send(true); | ||
}); | ||
|
||
// Still valid syntax -- START | ||
app.get("/send", function (req, res) { | ||
res.send(Buffer.from('whoop')); | ||
res.send({ some: 'json' }); | ||
res.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", function (req, response) { | ||
response.send(Buffer.from('whoop')); | ||
response.send({ some: 'json' }); | ||
response.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", (req, response) => { | ||
response.send(Buffer.from('whoop')); | ||
response.send({ some: 'json' }); | ||
response.send('<p>some html</p>'); | ||
}); | ||
|
||
app.get("/send", (req, res) => { | ||
res.send(Buffer.from('whoop')); | ||
res.send({ some: 'json' }); | ||
res.send('<p>some html</p>'); | ||
}); | ||
// Still valid syntax -- END |
Oops, something went wrong.