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 assert from 'assert' | |
export const warn = (logger) => (msg) => { | |
assert(logger, `'${logger}' is not supported in this environment`) | |
assert(logger.warn, `'${logger}.warn' is not supported in this environment`) | |
logger.warn("[validate.js] " + msg) | |
} |
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 assert from 'assert' | |
function warn(msg) { | |
assert(console, '`console` is not supported in this environment') | |
assert(console.warn, '`console.warn` is not supported in this environment') | |
console.warn("[validate.js] " + msg) | |
} |
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
function warn(msg) { | |
if (typeof console !== "undefined" && console.warn) { | |
console.warn("[validate.js] " + msg) | |
} | |
} |
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 |
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 { AuthService } from './authService' | |
const IS_AUTHENTICATED = process.env.REACT_APP_IS_AUTHENTICATED | |
export default class MockAuthService implements AuthService { | |
async login() { | |
console.info('Mocking login initialization.') | |
} | |
async logout() { |
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 createVendorAuthClient, { VendorAuthClient } from 'someauthservice'; | |
import { AuthService } from './authService' | |
import { VendorSession, Session } from '../../models/session' | |
export default class VendorAuthService implements AuthService { | |
client: VendorAuthClient; | |
redirectUri: string; | |
constructor() { |
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
export interface AuthService { | |
login(): Promise<void>; | |
logout(): Promise<void>; | |
isAuthenticated(): Promise<boolean>; | |
getJwtToken(): Promise<string>; | |
} |
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 _ from 'lodash/fp'; | |
export const indexBooksByAuthor = _.keyBy('authorId'); | |
export const getSomeValue = () => { | |
// some code ... | |
const booksByAuthor = indexBooksByAuthor(books); | |
// some more code ... |
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 _ from 'lodash'; | |
export const indexBooksByAuthor = (books) => { | |
return _.reduce(books, (acc, e) => { | |
acc[e.authorId] = e | |
return acc | |
}, {}); | |
} | |
export const getSomeValue = () => { |
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 _ from 'lodash'; | |
export const getSomeValue = () => { | |
// some code ... | |
const indexed = _.reduce(books, (acc, e) => { | |
acc[e.authorId] = e | |
return acc | |
}, {}); |