New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ember-json-serializer-meta

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ember-json-serializer-meta

Extensive extract metadata support for JSONSerializer.

  • 1.2.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ember-json-serializer-meta

Build Status npm version

So I heard you are working with custom APIs that are not either JSONAPI or REST but rather something in between, a hybrid. Then this addon is for you! It enables extracting metadata for all the Ember Data normalize*Response hooks.

ember install ember-json-serializer-meta

Works with Ember 1.13+

How it works

Flow chart

                                               ┌─ extractMetaFindAllResponse() ─────┐
                                               ├─ extractMetaFindHasManyResponse() ─┼─ extractMetaArrayResponse() ─────────────────────────────────┐
                                               ├─ extractMetaFindManyResponse() ────┤                                                              │
                                               ├─ extractMetaQueryResponse() ───────┘                                                              │
                                               │                                                                                                   │
                                               ├─ extractMetaFindRecordResponse() ─────────────────────────────────┐                               │
normalizeResponse() - normalizeMetaResponse() ─┼─ extractMetaFindBelongsToResponse() ──────────────────────────────┤                               │
                                               ├─ extractMetaQueryRecordResponse() ────────────────────────────────┤                               │
                                               │                                                                   │                               │
                                               ├─ extractMetaCreateRecordResponse() ─┐                             │                               │
                                               ├─ extractMetaDeleteRecordResponse() ─┼─ extractMetaSaveResponse() ─┴─ extractMetaSingleResponse() ─┴─ extractMetaResponse()
                                               └─ extractMetaUpdateRecordResponse() ─┘

API response

  {
    status: {
      errorCode: 0
    },
    records: [{
      id: 1,
      name: 'Tomster'
    }],
    pagination: {

    }
  }

By default such payload is not supported by the JSONSerializer, it is impossible to extract metadata with default extractMeta hook.

Here comes in the addon which adds another serializer hook for extracting meta for your custom API responses with JSONSerializer.

import extractMetaResponseMixin from 'ember-json-serializer-meta';

export default DS.JSONSerializer.extend(extractMetaResponseMixin, {
  extractMetaResponse(store, typeClass, payload/*, id, requestType*/) {
    if (payload && payload.pagination) {
      return payload.pagination;
    }
  }
});

Default implementation of extractMetaResponse will lookup meta property.

  {
    ...
    meta: {
      my: 'meta'
    }
    ...
  }

Contribution

This project follows Gitflow Workflow.

Installation

  • git clone this repository
  • yarn install

Running

Running Tests

  • yarn test (Runs ember try:each to test your addon against multiple Ember versions)
  • ember test
  • ember test --server

Building

  • ember build

For more information on using ember-cli, visit https://ember-cli.com/.

Keywords

FAQs

Package last updated on 10 Sep 2017

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc