Skip to content
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

Open
wants to merge 12 commits into
base: master
Choose a base branch
from

Conversation

simonprickett
Copy link
Contributor

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.

@simonprickett
Copy link
Contributor Author

@chayim is there someone I should ping to look at this major overhaul of the node code for node-redis 4? Thanks!

@simonprickett
Copy link
Contributor Author

@chayim @K-Jo can someone check this out please? thanks.

@simonprickett
Copy link
Contributor Author

@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?

@simonprickett
Copy link
Contributor Author

Can we merge this @chayim ?

@chayim chayim requested a review from leibale December 7, 2022 07:32
@chayim
Copy link
Contributor

chayim commented Dec 7, 2022

@leibale can you have a look? @simonprickett can you resolve the README conflict?

Copy link

@leibale leibale left a 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
Copy link

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",
Copy link

@leibale leibale Dec 7, 2022

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);
Copy link

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);
Copy link

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)));
Copy link

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}`));
Copy link

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..

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants