@feardread/feature-factory 4.0.3 → 4.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bundle.min.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +3 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factory/api.js +1 -1
- package/src/factory/thunk.js +11 -2
package/package.json
CHANGED
package/src/factory/api.js
CHANGED
|
@@ -8,7 +8,7 @@ import CacheFactory from './cache';
|
|
|
8
8
|
const CONFIG = {
|
|
9
9
|
// API Base URLs
|
|
10
10
|
baseUrls: {
|
|
11
|
-
production: process.env.REACT_APP_API_BASE_URL_PROD || '
|
|
11
|
+
production: process.env.REACT_APP_API_BASE_URL_PROD || 'http://fear.master.com/fear/api/',
|
|
12
12
|
development: process.env.REACT_APP_API_BASE_URL_DEV || 'http://localhost:4000/fear/api/',
|
|
13
13
|
test: process.env.REACT_APP_API_BASE_URL_TEST || 'http://localhost:3001/fear/api/',
|
|
14
14
|
},
|
package/src/factory/thunk.js
CHANGED
|
@@ -111,6 +111,7 @@ const createGenericThunk = (entity, prefix, options = {}) => {
|
|
|
111
111
|
useParams: false,
|
|
112
112
|
useIdInUrl: false,
|
|
113
113
|
customUrl: null,
|
|
114
|
+
customApiUrl: null,
|
|
114
115
|
...options,
|
|
115
116
|
};
|
|
116
117
|
|
|
@@ -123,6 +124,10 @@ const createGenericThunk = (entity, prefix, options = {}) => {
|
|
|
123
124
|
let apiCall;
|
|
124
125
|
const apiConfig = config.useParams ? { params: payload } : {};
|
|
125
126
|
|
|
127
|
+
if ( config.customApiUrl !== null ) {
|
|
128
|
+
API.instance.defaults.baseURL = config.customApiUrl;
|
|
129
|
+
}
|
|
130
|
+
|
|
126
131
|
switch (config.method) {
|
|
127
132
|
case HTTP_METHODS.GET:
|
|
128
133
|
apiCall = API.get(url, apiConfig);
|
|
@@ -156,18 +161,20 @@ const createGenericThunk = (entity, prefix, options = {}) => {
|
|
|
156
161
|
* Factory for creating Redux async thunks with standardized patterns
|
|
157
162
|
*/
|
|
158
163
|
export const ThunkFactory = {
|
|
164
|
+
API_URL: null,
|
|
159
165
|
/**
|
|
160
166
|
* Creates a GET request thunk (legacy method for backward compatibility)
|
|
161
167
|
* @param {string} entity - The entity name
|
|
162
168
|
* @param {string} prefix - The operation prefix
|
|
163
169
|
* @returns {Function} The created async thunk
|
|
164
170
|
*/
|
|
165
|
-
create: (entity, prefix) => {
|
|
171
|
+
create: (entity, prefix, apiUrl = ThunkFactory.API_URL) => {
|
|
166
172
|
validateThunkParams(entity, prefix);
|
|
167
173
|
|
|
168
174
|
const operation = STANDARD_OPERATIONS[prefix];
|
|
175
|
+
const options = {operation, customApiUrl: apiUrl};
|
|
169
176
|
if (operation) {
|
|
170
|
-
return createGenericThunk(entity, prefix,
|
|
177
|
+
return createGenericThunk(entity, prefix, options);
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
// Fallback to original behavior for custom prefixes
|
|
@@ -274,6 +281,8 @@ export const ThunkFactory = {
|
|
|
274
281
|
* @returns {Object} Standard operations object
|
|
275
282
|
*/
|
|
276
283
|
getStandardOperations: () => ({ ...STANDARD_OPERATIONS }),
|
|
284
|
+
getApiUrl: () => { return ThunkFactory.API_URL },
|
|
285
|
+
setApiUrl: (url) => { ThunkFactory.API_URL = url }
|
|
277
286
|
};
|
|
278
287
|
|
|
279
288
|
export default ThunkFactory;
|