-
Notifications
You must be signed in to change notification settings - Fork 36
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Updates Node Server for latest Node, Modules and Node-Redis v4 Client #99
base: master
Are you sure you want to change the base?
Conversation
@chayim is there someone I should ping to look at this major overhaul of the node code for node-redis 4? Thanks! |
@chayim this one was a lot of work that substantially improves the Node codebase and it's sat unmerged for a significant time. Can we get this merged? |
Can we merge this @chayim ? |
@leibale can you have a look? @simonprickett can you resolve the README conflict? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Overall looks good, I left some comments.. :)
@@ -1,4 +1,4 @@ | |||
FROM node:10 | |||
FROM node:16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
move to 18 (current LTS)?
"scripts": { | ||
"start": "node server.js", | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
"dev": "./node_modules/nodemon/bin/nodemon.js", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
npm adds "./node_modules/.bin" to the path, "nodemon" should work (without the path)
const queryString = req.query.q; | ||
const offset = Number((req.query.offset)?req.query.offset:'0'); | ||
const limit = Number((req.query.limit)?req.query.limit:'10'); | ||
const offset = Number((req.query.offset) ? req.query.offset : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to req.query.offset ?? 0
(it was added in node 14.0.0 https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Nullish_coalescing#browser_compatibility)
edit: and validate it's a positive number
const offset = Number((req.query.offset)?req.query.offset:'0'); | ||
const limit = Number((req.query.limit)?req.query.limit:'10'); | ||
const offset = Number((req.query.offset) ? req.query.offset : 0); | ||
const limit = Number((req.query.limit) ? req.query.limit : 10); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
change to req.query.limit ?? 10
edit: and validate it's not over 500 (or any other number)
res.json(result); | ||
}); | ||
}); | ||
app.get('/api/1.0/movies/group_by/:field', async (req, res) => res.json(await searchService.getMovieGroupBy(req.params.field))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
https://www.npmjs.com/package/express-promise-router can use that to clean the code a bit
app.listen(serverPort, () => { | ||
console.log(`RediSearch Node listening at http://localhost:${serverPort}`); | ||
}); | ||
app.listen(serverPort, () => console.log(`RediSearch Node REST Server listening at http://localhost:${serverPort}`)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the callback might get an error argument..
This updates the Node Server to use Node 14+, top level await, modules, updates the Express dependency to the latest version and upgrades Node-Redis to version 4.