How to pass Redis connection to module?

You need to require /app/config/config.js from your module.

Also:

If you want to use environment variables you need to change core files and make sure you discard changes with GIT with every update.

lib/setup/redis.js

const config = require('./config');

if (config.redis) {
    const redis = require('redis');
    global.redisClient = redis.createClient(config.redis === true ? 'redis://redis' : process.env.REDIS_URL);
}

module.exports = global.redisClient;

This way I set redis to NO(unchecked) on the UI and load it from dotenv

2 Likes