Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
dimdenGD committed Oct 26, 2024
1 parent c9b166a commit 6f84563
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/declarative.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,8 +149,8 @@ module.exports = function compileDeclarative(cb, app) {
allowedIdentifiers.includes(id) ||
id === req ||
id === res ||
(identifiers[i - 2] === 'req' && identifiers[i - 1] === 'params') ||
(identifiers[i - 2] === 'req' && identifiers[i - 1] === 'query') ||
(identifiers[i - 2] === req && identifiers[i - 1] === 'params') ||
(identifiers[i - 2] === req && identifiers[i - 1] === 'query') ||
id === queryName ||
id === paramsName ||
queries.includes(id) ||
Expand Down
7 changes: 7 additions & 0 deletions tests/tests/res/declarative.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,12 @@ app2.get('/test11', (req, res) => {
res.send(req.query);
});

app2.get('/test12/:id', (req, res) => {
req;
let params = "1";
res.send(params);
});

app.listen(13333, async () => {
app2.listen(13334, async () => {
console.log('Server is running on port 13333');
Expand All @@ -104,6 +110,7 @@ app.listen(13333, async () => {
fetch('http://localhost:13334/test9/123?name=test').then(res => res.text()),
fetch('http://localhost:13334/test10/123?name=test').then(res => res.text()),
fetch('http://localhost:13334/test11?name=test').then(res => res.text()),
fetch('http://localhost:13334/test12/123?name=test').then(res => res.text()),

fetch('http://localhost:13334/test').then(res => res.text()),
fetch('http://localhost:13334/test2?name=test&name2=test2').then(res => res.text()),
Expand Down

0 comments on commit 6f84563

Please sign in to comment.