express icon indicating copy to clipboard operation
express copied to clipboard

fix: update online example to support Redis v4+ and remove outdated dependency

Open vinybk opened this issue 11 months ago • 1 comments

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

The online example was broken due to Redis updates and its reliance on the outdated online package by TJ Holowaychuk, which is no longer maintained and has only 24 weekly downloads.

I considered removing the example or replacing online with another library but opted to add a new file that substitutes the dependency.

Key changes:

  • Removed dependency on online by creating a new file, online-tracker.js, which replicates the original functionality.
  • Switched from callbacks to promises.
  • Updated Redis commands and added try/catch for error handling.
  • Refactored Redis initialization into a dedicated function initializeRedis to make sure that it completes before the server starts.

Note: the original online module was optimized for performance. The substitute file prioritizes simplicity to make it easier to understand, considering it is now part of an example rather than a standalone module.

Tested locally with:

  • Redis 7.0.15
  • Node.js 22.12.0
  • Express 5.0.1
  • Debian 12

Let me know if any changes are needed!

vinybk avatar Jan 19 '25 23:01 vinybk

Okay, appreciate the inputs. I'll work on that changes and re-request review once it's done.

vinybk avatar Jan 20 '25 22:01 vinybk