# normalizr-middleware

> Combines redux middleware and normalizr to make flattening nested data a snap

Latest version **1.0.1** (published 2016-01-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install normalizr-middleware
pnpm add normalizr-middleware
yarn add normalizr-middleware
bun add normalizr-middleware
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-01-01 |
| First published | 2016-01-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Will Binns-Smith |
| Maintainers | wbinnssmith |
| Keywords | normalizr, redux, redux-middleware |

## Links

- npm: https://www.npmjs.com/package/normalizr-middleware
- Repository: https://github.com/wbinnssmith/redux-normalizr-middleware
- Homepage: https://github.com/wbinnssmith/redux-normalizr-middleware#readme
- Issues: https://github.com/wbinnssmith/redux-normalizr-middleware/issues
- npm.io page: https://npm.io/package/normalizr-middleware

## Dependencies (2)

- [normalizr](https://npm.io/package/normalizr.md) ^1.4.0
- [object-assign](https://npm.io/package/object-assign.md) ^4.0.1

## Alternatives

- [@sindresorhus/slugify](https://npm.io/package/@sindresorhus/slugify.md) — 3.7M weekly downloads
- [solid-js](https://npm.io/package/solid-js.md) — 2.7M weekly downloads
- [expo-glass-effect](https://npm.io/package/expo-glass-effect.md) — 2.5M weekly downloads
- [nanoassert](https://npm.io/package/nanoassert.md) — 780.8K weekly downloads
- [@ffmpeg/ffmpeg](https://npm.io/package/@ffmpeg/ffmpeg.md) — 529.5K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-01-01
- 1.0.0 — 2016-01-01

## README

# redux-normalizr-middleware
Combines the power of redux middleware and @gaearon's
[normalizr](https://github.com/gaearon/normalizr) to make flattening
relational, nested data a snap.

Use with [redux-thunk](https://github.com/gaearon/redux-thunk) or
[redux-promise-middleware](https://github.com/pburtchaell/redux-promise-
middleware) to easily request and store your API's response in a
database-like fashion in your redux apps!

For an example of a more manual implementation, check out [the
real-world example in redux](https://github.com/rackt/redux/tree/master/examples/real-world)

## Installation
`npm install --save redux-normalizr-middleware`

## Usage Place this middleware before anything that expects flattened
data, and after anything that makes the nested data available (so before
something like [redux-thunk] or [redux-promise-middleware]).

redux-normalizr-middleware assumes that your actions comply with FSA and
that your nested data is available as the `payload` property in your
action, and will normalize and store the flattened data in the same
`payload` property. Opt into redux-normalizr-middleware by supplying a
[normalizr schema] as `schema` in your action's `meta` object.

## Example
```js
  import normalizrMiddleware from 'redux-normalize-middleware';

  // import a schema defined using normalizr's `Schema`s to apply
  // to the response
  import todoSchema from './todo-schema';

  const createStoreWithNormalizr =
    applyMiddleware(normalizrMiddleware())(createStore);

    // See the redux real-world example for this reducer pattern
    const store = createStoreWithNormalizr({
      entitiesReducer: () => {},
      todosByAuthor: () => {}
    });

  // This could be dispatched from redux-thunk or redux-promise-middleware
  store.dispatch({
    type: 'TODO_RECEIVED',
    payload: nestedTodoResponse,
    meta: {
      schema: todoSchema
    }
  });
```

In the above, middlware following redux-normalizr-middleware and reducers
connected to the redux store will receive the action payload as normalized,
flattened data with `entities` and `results`!

---
_Source: https://npm.io/package/normalizr-middleware · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
