🚨 Shai-Hulud Strikes Again:834 Packages Compromised.Technical Analysis →
Socket
Book a DemoInstallSign in
Socket

normalize-json-api

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

normalize-json-api

Normalizes JSON API responses for Redux and Flux applications

latest
Source
npmnpm
Version
0.1.1
Version published
Weekly downloads
1
Maintainers
1
Weekly downloads
 
Created
Source

normalize-json-api build status npm version

Normalizes JSON API responses according to a schema for Flux and Redux apps. More on JSON API. Thanks to paularmstrong and Dan Abramov for building normalizr where the original idea of this library came from :)

Installation

npm install --save normalize-json-api

The Problem

  • You have a JSON API sideloaded objects ;
  • You want to port your app to Flux or Redux;
  • You noticed it's hard for Stores (or Reducers) to consume data from nested API responses.

normalize-json-api takes JSON API and

For example,

{
  data: {
    id: 1,
    type: 'articles',
    attributes: {
      title: 'Shoes',
      'is-favorite': false,
    },
    relationships: {
      author: {
        data: {
          type: 'users',
          id: 9,
        },
      },
    },
  },
  included: [
    {
      type: 'users',
      id: 9,
      attributes: {
        'first-name': 'Marie',
        'last-name': 'Brizard',
        twitter: 'mb',
      },
    },
  ],
}

can be normalized to

{
  results: {
    articles: [1],
    users: [9],
  },
  entities: {
    articles: {
      1: {
        id: 1,
        type: 'articles',
        title: 'Shoes',
        isFavorite: false,
        author: 9,
      },
    },
    users: {
      9: {
        id: 9,
        type: 'users',
        firstName: 'Marie',
        lastName: 'Brizard',
        twitter: 'mb',
      },
    },
  },
}

Features

TODO

Usage

TODO

Credits

normalize-json-api was inspired heavily by normalizr

Keywords

flux

FAQs

Package last updated on 10 Sep 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts