-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
75a8df4
commit c8b5ced
Showing
20 changed files
with
100 additions
and
91 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,5 @@ | ||
import voltran from './universal/partials/withBaseComponent'; | ||
import { SERVICES } from './universal/utils/constants'; | ||
import { ClientApiManager, ServerApiManager } from './universal/core/api'; | ||
import apiService, { ClientApiManager, ServerApiManager } from './universal/core/apiService'; | ||
|
||
export default voltran; | ||
export { SERVICES, ClientApiManager, ServerApiManager }; | ||
export { ClientApiManager, ServerApiManager, apiService }; |
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
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
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
11 changes: 11 additions & 0 deletions
11
src/universal/core/apiService/apiManager/ClientApiManager.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
import createApiClient from '../utils/createApiClient'; | ||
import BaseApiManager from './BaseApiManager'; | ||
|
||
export default (config, timeout) => { | ||
const apiManager = new BaseApiManager({ | ||
baseURL: config.clientUrl || config.url || config.serverUrl || '/', | ||
timeout | ||
}); | ||
|
||
return createApiClient(apiManager); | ||
}; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default as BaseApiManager } from './BaseApiManager'; | ||
export { default as ClientApiManager } from './ClientApiManager'; | ||
export { default as ServerApiManager } from './ServerApiManager'; |
9 changes: 9 additions & 0 deletions
9
src/universal/core/apiService/apiManagerCache/ClientApiManagerCache.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* istanbul ignore file */ | ||
import ClientApiManager from '../apiManager/ClientApiManager'; | ||
import createCache from '../utils/createCache'; | ||
|
||
const { services, timeouts } = require('__APP_CONFIG__'); | ||
|
||
const cache = createCache(ClientApiManager, services, timeouts.clientApiManager); | ||
|
||
export default cache; |
9 changes: 9 additions & 0 deletions
9
src/universal/core/apiService/apiManagerCache/ServerApiManagerCache.js
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
/* istanbul ignore file */ | ||
import ServerApiManager from '../apiManager/ServerApiManager'; | ||
import createCache from '../utils/createCache'; | ||
|
||
const { services, timeouts } = require('__APP_CONFIG__'); | ||
|
||
const cache = createCache(ServerApiManager, services, timeouts.serverApiManager); | ||
|
||
export default cache; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
export { default as ServerApiManagerCache } from './ServerApiManagerCache'; | ||
export { default as ClientApiManagerCache } from './ClientApiManagerCache'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { ServerApiManagerCache, ClientApiManagerCache } from './apiManagerCache'; | ||
|
||
const getApiService = () => { | ||
const isBrowser = typeof window !== 'undefined'; | ||
|
||
return isBrowser ? ClientApiManagerCache : ServerApiManagerCache; | ||
}; | ||
|
||
const apiService = getApiService(); | ||
export default apiService; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
export { default } from './apiService'; | ||
export { default as ClientApiManager } from './apiManagerCache/ClientApiManagerCache'; | ||
export { default as ServerApiManager } from './apiManagerCache/ServerApiManagerCache'; |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import freezeServices from './freezeServices'; | ||
|
||
const createCache = (ApiManager, services, timeout) => { | ||
const cache = {}; | ||
const frozenServicesData = freezeServices(services); | ||
|
||
Object.entries(services).forEach(entity => { | ||
const [serviceKey, serviceValues] = entity; | ||
cache[frozenServicesData[serviceKey]] = ApiManager(serviceValues, timeout); | ||
}); | ||
|
||
return cache; | ||
}; | ||
|
||
export default createCache; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
function freezeServices(services) { | ||
return Object.freeze( | ||
Object.keys(services).reduce((obj, val) => { | ||
// eslint-disable-next-line no-param-reassign | ||
obj[val] = val; | ||
return obj; | ||
}, {}) | ||
); | ||
} | ||
|
||
export default freezeServices; |
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
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