Created
April 19, 2020 16:10
-
-
Save jakerobers/507c7663e3383659ef435f47d0807eaf to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ServiceNotFoundError } from '../index' | |
import VendorAuthService from './vendorAuthService' | |
import MockAuthService from './mockAuthService' | |
const defaultEnv = process.env.NODE_ENV | |
const defaultIsOffline = !!process.env.REACT_APP_OFFLINE | |
export default function(environment = defaultEnv, offline = defaultIsOffline) { | |
let service | |
if (offline || environment === 'test') { | |
service = new MockAuthService() | |
} else if (environment === 'production' || environment === 'development') { | |
service = new VendorAuthService() | |
} else { | |
throw new ServiceNotFoundError(`Could not find environment: ${environment}`) | |
} | |
return service | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment