Created configuration files by NODE_ENV

This commit is contained in:
apanizo 2018-08-08 17:24:01 +02:00
parent 0212bcb162
commit b26ad98237
5 changed files with 55 additions and 0 deletions

View File

@ -0,0 +1,8 @@
// @flow
import { TX_SERVICE_HOST } from '~/config/names'
const devConfig = {
[TX_SERVICE_HOST]: 'https://safe-transaction-history.dev.gnosisdev.com/api/v1/',
}
export default devConfig

28
src/config/index.js Normal file
View File

@ -0,0 +1,28 @@
// @flow
import { ensureOnce } from '~/utils/singleton'
import { TX_SERVICE_HOST } from '~/config/names'
import devConfig from './development'
import testConfig from './testing'
import prodConfig from './production'
const configuration = () => {
if (process.env.NODE_ENV === 'test') {
return testConfig
}
if (process.env.NODE_ENV === 'production') {
return prodConfig
}
return devConfig
}
const getConfig = ensureOnce(configuration)
export const getTxServiceHost = () => {
const config = getConfig()
return config[TX_SERVICE_HOST]
}
export const getTxServiceUriFrom = (safeAddress: string) => `safes/${safeAddress}/transactions/`

3
src/config/names.js Normal file
View File

@ -0,0 +1,3 @@
// @flow
export const TX_SERVICE_HOST = 'tsh'

8
src/config/production.js Normal file
View File

@ -0,0 +1,8 @@
// @flow
import { TX_SERVICE_HOST } from '~/config/names'
const prodConfig = {
[TX_SERVICE_HOST]: 'https://safe-transaction-history.dev.gnosisdev.com/api/v1/',
}
export default prodConfig

8
src/config/testing.js Normal file
View File

@ -0,0 +1,8 @@
// @flow
import { TX_SERVICE_HOST } from '~/config/names'
const testConfig = {
[TX_SERVICE_HOST]: 'http://localhost:8080/api/v1/',
}
export default testConfig