Skip to content

Instantly share code, notes, and snippets.

@jakerobers
Created April 19, 2020 16:10
Show Gist options
  • Save jakerobers/507c7663e3383659ef435f47d0807eaf to your computer and use it in GitHub Desktop.
Save jakerobers/507c7663e3383659ef435f47d0807eaf to your computer and use it in GitHub Desktop.
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