express
express copied to clipboard
fix: search example to support Redis v4+ and Express 4/5
This PR updates the Search example to address issues caused by breaking changes in Redis v4+ and Express 5.
Key changes include:
- Replacing
saddwithsAddandsmemberswithsMembersfor Redis v4+ compatibility. - Using
{0,1}syntax for optional parameters instead of?to support Express 5. - Adding error handling for Redis connection and commands.
These changes ensure the example works seamlessly.
Tested locally with: Redis 7.0.15 Node.js 22.12.0 Express 5.0.1 and 4.21.2 Debian 12
Note: Adding automated tests for this example could help catch issues like this sooner. If you think it's worthwhile, I’d be glad to help implement them.
Hi @wesleytodd, I've made the requested changes:
- Updated optional route syntax to
/{:query}. - Refactored Redis initialization into a dedicated function
initializeRedisto make sure that it completes before the server starts.
I think this aligns with your feedback, but please let me know if I misunderstood or missed anything. Thanks!