shuttlepro-shared 1.1.100 → 1.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/config/redis.js +3 -2
- package/package.json +1 -1
package/config/redis.js
CHANGED
|
@@ -53,12 +53,13 @@ const publishToChannel = async (channel, message) => {
|
|
|
53
53
|
* @param {string} channel - The Redis Pub/Sub channel
|
|
54
54
|
* @param {function} callback - Callback function to handle messages
|
|
55
55
|
*/
|
|
56
|
-
const subscribeToChannel = async (channel, callback) => {
|
|
56
|
+
const subscribeToChannel = async (channel, callback, expiry = false) => {
|
|
57
57
|
try {
|
|
58
58
|
await connectRedis();
|
|
59
59
|
await subscriber.subscribe(channel, (message) => {
|
|
60
60
|
console.log(`📥 Message received on channel: ${channel}`);
|
|
61
|
-
callback(
|
|
61
|
+
if (expiry) callback(message);
|
|
62
|
+
else callback(JSON.parse(message));
|
|
62
63
|
});
|
|
63
64
|
} catch (err) {
|
|
64
65
|
console.error("❌ Error subscribing to channel:", err);
|