all files / lib/strategy/ LoadAPIKeyFromConfigStrategy.js

81.82% Statements 9/11
66.67% Branches 4/6
100% Functions 2/2
81.82% Lines 9/11
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                                       
'use strict';
 
var LoadAPIKeyConfigStrategy = require('./LoadAPIKeyConfigStrategy');
 
/**
 * Represents a strategy that that loads an API key specified in config into the configuration.
 *
 * @class
 */
function LoadAPIKeyFromConfigStrategy () {
}
 
LoadAPIKeyFromConfigStrategy.prototype.process = function (config, callback) {
  Iif (!config.client || !config.client.apiKey) {
    return callback(null, config);
  }
 
  var apiKey = config.client.apiKey;
 
  Eif (apiKey.file) {
    var loadKeyStrategy = new LoadAPIKeyConfigStrategy(apiKey.file, true);
    loadKeyStrategy.process(config, callback);
  } else {
    callback(null, config);
  }
};
 
module.exports = LoadAPIKeyFromConfigStrategy;