express icon indicating copy to clipboard operation
express copied to clipboard

fix: search example to support Redis v4+ and Express 4/5

Open vinybk opened this issue 1 year ago • 1 comments

This PR updates the Search example to address issues caused by breaking changes in Redis v4+ and Express 5.

Key changes include:

  • Replacing sadd with sAdd and smembers with sMembers for 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.

vinybk avatar Jan 12 '25 19:01 vinybk

Hi @wesleytodd, I've made the requested changes:

  • Updated optional route syntax to /{:query}.
  • Refactored Redis initialization into a dedicated function initializeRedis to 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!

vinybk avatar Jan 13 '25 18:01 vinybk