- Predictable and Ready-to-go api reducer to handle common network result for Rest API ,E.g Domain,Network,Api Reducer
- Support swagger.json,documentation as code
- Support file upload
npm install redux-api-middleware-addon --save
https://github.com/chungchi300/redux-api-middleware-addon/blob/master/src/common/swagger.js
import SWAGGER from 'swagger.js';
store.dispatch(Action.setProtocol('https'));
store.dispatch(Action.setSwagger(SWAGGER));
store.dispatch(
Action.setHeaders({
// 'X-Token': 'base64TokenForApiCall',
Accept: 'application/json',
['Content-Type']: 'application/json',
})
);
store
.dispatch(
Action.request(
'/pet/findByStatus',
{
method: 'get',
data: { status: 'available' },
subst: null,
},
BASIC
)
)
.then(res => console.log(res));
store
.dispatch(
Action.request(
'/pet',
{
method: 'post',
data: {
name: 'ronald',
id: 3,
photoUrls: [
'https://upload.wikimedia.org/wikipedia/commons/thumb/2/26/Letter_d.svg/1200px-Letter_d.svg.png',
],
},
},
BASIC
)
)
.then(res => console.log(res));
store
.dispatch(
Action.request(
'/pet/findByStatus',
{
method: 'get',
data: { status: 'available' },
subst: null,
},
entity('PETS_BY_ID')
)
)
.then(res => console.log(res));
- SET_SWAGGER
- Request
- SET_HEADER(default empty)
- SET_PROTOCOL(default http)
- Generate Basic types
- Generate Get Entity types
//TODO Generate update,delete,create which help network reducer record which api has api result that failed
- network (reducer,where is network result located)
- domain (reducer,where is CRUD resource result located)
- api (reducer,where is the api located)