@feardread/feature-factory 1.1.7 → 1.1.9

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@feardread/feature-factory",
3
- "version": "1.1.7",
3
+ "version": "1.1.9",
4
4
  "main": "dist/index.js",
5
5
  "scripts": {
6
6
  "build": "rollup -c",
@@ -5,7 +5,7 @@ import cache from "../cache/cache.js";
5
5
 
6
6
 
7
7
 
8
- const API = ( options ) => {
8
+ const InstanceFactory = ( options ) => {
9
9
 
10
10
  const API_BASE_URL = (options.API_BASE_URL)
11
11
  ? options.API_BASE_URL
@@ -77,4 +77,4 @@ const API = ( options ) => {
77
77
 
78
78
 
79
79
 
80
- export default API;
80
+ export default InstanceFactory;
@@ -1,5 +1,5 @@
1
1
  import { createSlice, createAsyncThunk } from '@reduxjs/toolkit';
2
- import API from "../api/api.js";
2
+ import InstanceFactory from "../api/factory.js";
3
3
 
4
4
  const StateFactory = (entity, data = null) => ({
5
5
  [entity]: data,
@@ -9,9 +9,8 @@ const StateFactory = (entity, data = null) => ({
9
9
  });
10
10
 
11
11
  const FeatureFactory = (sliceName, endpoint, options = {}) => {
12
- const { initialData, service } = options;
13
12
  const apiEndpoint = `${sliceName}/${endpoint}`;
14
- const apiInstance = API({
13
+ const apiInstance = InstanceFactory({
15
14
  API_BASE_URL: 'http://fear.master.com:4000/fear/api',
16
15
  JWT_TOKEN: 'fear-x-token'
17
16
  });
@@ -33,7 +32,7 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
33
32
  );
34
33
 
35
34
  const fetchOne = createAsyncThunk(
36
- `${name}/one`,
35
+ `${sliceName}/one`,
37
36
  async (id, { rejectWithValue }) => {
38
37
  return await apiInstance.get(`${sliceName}/${id}`)
39
38
  .then((response) => {
@@ -115,14 +114,14 @@ const FeatureFactory = (sliceName, endpoint, options = {}) => {
115
114
  })
116
115
 
117
116
  return {
118
- API: API({ API_BASE_URL: 'http://fear.master.com:4000/fear/api' }),
119
117
  reducer: slice.reducer,
120
118
  actions: slice.actions,
119
+ instance: apiInstance,
121
120
  asyncActions: {
122
121
  fetch,
123
122
  fetchOne,
124
123
  search,
125
- serviceActions: (service) ? service : {}
124
+ service: (options.service) ? options.service : null
126
125
  },
127
126
 
128
127
  }
package/src/index.js CHANGED
@@ -1,2 +1,5 @@
1
1
 
2
2
  export { default as FeatureFactory } from "./factory/factory.js";
3
+
4
+ export { default as InstanceFactory } from "./api/factory.js";
5
+