all files / src/ index.js

100% Statements 6/6
100% Branches 2/2
100% Functions 1/1
100% Lines 6/6
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                                                       
'use strict';
 
var EXPORTABLE_RESOURCES;
 
EXPORTABLE_RESOURCES = {
   Request: './Request',
   APIError: './APIError',
   JWTSecuredRequest: './JWTSecuredRequest',
   ResponseBuilder: './ResponseBuilder',
   SilvermineResponseBuilder: './SilvermineResponseBuilder',
   responseBuilderHandler: './responseBuilderHandler',
   JWTValidator: './JWTValidator',
};
 
module.exports = {
 
   /**
    * This function provides a way of getting named classes and functions that
    * we export from our library without needing them to be required when the
    * file is loaded. If they were required when this file was loaded, then all
    * their dependencies would need to be found. If someone is not using one of
    * our classes (e.g. JWTSecuredRequest) they should not be required to pull
    * in (or themselves provide) its dependencies (e.g. jwt-simple).
    */
   get: function(resourceName) {
      if (EXPORTABLE_RESOURCES[resourceName]) {
         return require(EXPORTABLE_RESOURCES[resourceName]); // eslint-disable-line global-require
      }
 
      throw new Error('No exportable resource by the name "' + resourceName + '"');
   },
 
};