all files / dist/config/ redis.js

88.89% Statements 8/9
91.67% Branches 11/12
100% Functions 1/1
88.89% Lines 8/9
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68                              18×                                             18×                                              
'use strict';
 
Object.defineProperty(exports, "__esModule", {
  value: true
});
// get parameters from the environment or use defaults
var host = process.env.REDIS_HOST || '127.0.0.1';
var port = process.env.REDIS_PORT || 6379;
var db = process.env.REDIS_DB || 0;
var password = process.env.REDIS_PASS || null;
 
/**
 * Redis configs.
 *
 * constructor  - the redis client constructor method (package)
 * args         - the arguments to pass to the constructor
 * buildNew     - is to use the `new` keyword on the the constructor?
 */
exports.default = {
  redis: function redis(api) {
 
    Iif (process.env.FAKEREDIS === 'false' || process.env.REDIS_HOST !== undefined) {
 
      return {
        '_toExpand': false,
 
        client: {
          constructor: require('ioredis'),
          args: [{ port: port, host: host, password: password, db: db }],
          buildNew: true
        },
        subscriber: {
          constructor: require('ioredis'),
          args: [{ port: port, host: host, password: password, db: db }],
          buildNew: true
        },
        tasks: {
          constructor: require('ioredis'),
          args: [{ port: port, host: host, password: password, db: db }],
          buildNew: true
        }
      };
    } else {
 
      return {
        '_toExpand': false,
 
        client: {
          constructor: require('fakeredis').createClient,
          args: [port, host, { fast: true }],
          buildNew: false
        },
        subscriber: {
          constructor: require('fakeredis').createClient,
          args: [port, host, { fast: true }],
          buildNew: false
        },
        tasks: {
          constructor: require('fakeredis').createClient,
          args: [port, host, { fast: true }],
          buildNew: false
        }
      };
    }
  }
};
//# sourceMappingURL=redis.js.map