@feardread/feature-factory 5.0.5 → 5.0.7
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 +2 -2
- package/dist/index.esm.js +3 -3
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/factory/api.js +9 -8
- package/src/factory/index.js +0 -1
- package/src/factory/thunk.js +0 -4
package/package.json
CHANGED
package/src/factory/api.js
CHANGED
|
@@ -6,39 +6,39 @@ import CacheFactory from './cache';
|
|
|
6
6
|
* Environment-based configuration
|
|
7
7
|
*/
|
|
8
8
|
const CONFIG = {
|
|
9
|
+
BASE_URL: null,
|
|
9
10
|
// API Base URLs
|
|
10
11
|
baseUrls: {
|
|
11
12
|
production: process.env.REACT_APP_API_BASE_URL_PROD || 'http://fear.master.com/fear/api/',
|
|
12
13
|
development: process.env.REACT_APP_API_BASE_URL_DEV || 'http://localhost:4000/fear/api/',
|
|
13
14
|
test: process.env.REACT_APP_API_BASE_URL_TEST || 'http://localhost:3001/fear/api/',
|
|
14
15
|
},
|
|
15
|
-
|
|
16
|
-
// Token configuration
|
|
17
16
|
tokenNames: {
|
|
18
17
|
bearer: 'Authorization',
|
|
19
18
|
custom: process.env.REACT_APP_JWT_TOKEN_HEADER || 'x-token',
|
|
20
19
|
},
|
|
21
|
-
|
|
22
|
-
// Cache keys
|
|
23
20
|
cacheKeys: {
|
|
24
21
|
auth: 'auth',
|
|
25
22
|
refreshToken: 'refresh_token',
|
|
26
23
|
userPrefs: 'user_preferences',
|
|
27
24
|
},
|
|
28
|
-
|
|
29
|
-
// Request configuration
|
|
30
25
|
timeout: parseInt(process.env.REACT_APP_API_TIMEOUT) || 30000,
|
|
31
26
|
retryAttempts: parseInt(process.env.REACT_APP_API_RETRY_ATTEMPTS) || 3,
|
|
32
27
|
retryDelay: parseInt(process.env.REACT_APP_API_RETRY_DELAY) || 1000,
|
|
33
28
|
};
|
|
34
29
|
|
|
30
|
+
const setBaseUrl = (uri) => {
|
|
31
|
+
CONFIG.BASE_URL = uri || CONFIG.baseUrls['development'];
|
|
32
|
+
getBaseUrl();
|
|
33
|
+
};
|
|
35
34
|
/**
|
|
36
35
|
* Gets the appropriate base URL for the current environment
|
|
37
36
|
* @returns {string} Base URL
|
|
38
37
|
*/
|
|
39
38
|
const getBaseUrl = () => {
|
|
40
|
-
const env =
|
|
41
|
-
|
|
39
|
+
const env = process.env.NODE_ENV || 'development';
|
|
40
|
+
if (!CONFIG.BASE_URL) CONFIG.BASE_URL = CONFIG.baseUrls[env] || CONFIG.baseUrls.development
|
|
41
|
+
return CONFIG.BASE_URL;
|
|
42
42
|
};
|
|
43
43
|
|
|
44
44
|
/**
|
|
@@ -525,6 +525,7 @@ const API = {
|
|
|
525
525
|
// Configuration access
|
|
526
526
|
config: CONFIG,
|
|
527
527
|
getBaseUrl,
|
|
528
|
+
setBaseUrl
|
|
528
529
|
};
|
|
529
530
|
|
|
530
531
|
// Add event listener for auth failures (optional)
|
package/src/factory/index.js
CHANGED
|
@@ -176,7 +176,6 @@ export function FeatureFactory(entity, reducers = {}, endpoints = null) {
|
|
|
176
176
|
manager: createReducerManager,
|
|
177
177
|
inject: mergeObjects,
|
|
178
178
|
create: createFactorySlice,
|
|
179
|
-
|
|
180
179
|
// Utility methods
|
|
181
180
|
getEntityName: () => entity,
|
|
182
181
|
getAdapter: () => adapter,
|
package/src/factory/thunk.js
CHANGED
|
@@ -52,10 +52,6 @@ const validateThunkParams = (entity, prefix) => {
|
|
|
52
52
|
const buildUrl = (entity, prefix, params = {}, useIdInUrl = false) => {
|
|
53
53
|
let url = `${entity}`;
|
|
54
54
|
|
|
55
|
-
if( prefix === 'one') {
|
|
56
|
-
url += `/${params.id}`;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
55
|
if (useIdInUrl && params?.id) {
|
|
60
56
|
url += `/${params.id}`;
|
|
61
57
|
} else if (!useIdInUrl || prefix !== 'one') {
|