Mappersmith Redux Middleware
MappersmithReduxMiddleware is a middleware for mappersmith which dispatches your request lifecycle to a redux store
Installation
NPM
npm install mappersmith-redux-middleware --save# yarn add mappersmith-redux-middleware
Browser
Download the tag/latest version from the dist folder.
Usage
Configure the middleware with your redux store and add it to your manifest, like:
const client =
The events will follow the pattern:
type: 'mappersmith/<phase>/<resource-name>/<resource-method>' payload: /* */
where phase
can be: request
, response
or failure
. Examples:
clientUserall admin: 'true' // request event// {// type: 'mappersmith/request/User/all',// payload: {// params: { admin: true },// headers: {},// body: null// }// }//// response event// {// type: 'mappersmith/response/User/all',// payload: {// status: 200,// headers: { 'content-type': 'application/json' },// data: [// { id: 1, name: 'John Doe' },// /* ... */// ]// }// }
In case of failure:
clientUserall admin: 'true' // request event// {// type: 'mappersmith/request/User/all',// payload: {// params: { admin: true },// headers: {},// body: null// }// }//// response event// {// type: 'mappersmith/failure/User/all',// payload: {// status: 503,// headers: { 'content-type': 'application/json' },// data: {// error: 'Critical error!'// }// }// }
Running all tests
yarn test
Compile and release
NODE_ENV=production yarn build
License
See LICENSE for more details.