Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

interfacer

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

interfacer - npm Package Compare versions

Comparing version 0.0.9 to 0.1.0

9

package.json
{
"name": "interfacer",
"version": "0.0.9",
"version": "0.1.0",
"description": "Module for working with REST API",

@@ -58,2 +58,3 @@ "main": "lib/index.js",

"fetch-mock": "^5.1.5",
"flow-bin": "^0.43.0",
"jest": "^18.1.0",

@@ -64,2 +65,3 @@ "jsdoc": "^3.4.0",

"mocha-jsdom": "^1.1.0",
"nock": "^9.0.11",
"react": "^15.4.1",

@@ -75,5 +77,3 @@ "react-addons-test-utils": "^15.4.1",

"sinon-chai": "^2.8.0",
"tmp": "0.0.28",
"flow-bin": "^0.43.0",
"nock": "^9.0.11"
"tmp": "0.0.28"
},

@@ -83,4 +83,5 @@ "dependencies": {

"isomorphic-fetch": "^2.2.1",
"normalizr": "^3.2.2",
"request": "^2.81.0"
}
}

@@ -11,3 +11,5 @@ # Interfacer.js

* Customizable query construction
* Optional [normalizr](https://github.com/paularmstrong/normalizr) integration
## How to install

@@ -117,4 +119,8 @@

| `querybuilder` | Function that transform `query` object into a query string | `function`| `querybuilder`
| `makeBody` | Function that'll be run on body, right before request is made. | `function` | `body => body`
| `makeBody` | Function that'll be run on body, right before request is made. | `function` | `body => body`|
| `schema` | If you're using [normalizr](https://github.com/paularmstrong/normalizr) you can specify, response will be normalized using this schema. | `object` | |
##### **Note on normalization:**
Normalization of the response will take place **after** `flatMethod` is applied. Also `schema` property can be only configured in either `Interface level` or `Request level` config, as it doesn't really make sense to use one schema for all requests.
## URL Queries

@@ -121,0 +127,0 @@

@@ -25,4 +25,5 @@ // @flow

makeBody: callConfig.makeBody || localConfig.makeBody || globalConfig.makeBody,
schema: callConfig.schema || localConfig.schema
});
export default composeConfigs;
// @flow
import fetch from 'isomorphic-fetch';
import { normalize } from 'normalizr';
import { constructTrack, saveTrack, getTrack } from './memoization';

@@ -31,2 +32,4 @@ import { composeUrl } from './helpers';

.then(res => (request.flatMethod && request.flatMethod(res)) || res.json())
// eslint-disable-next-line no-confusing-arrow
.then(res => request.schema && normalize ? normalize(res, request.schema) : res)
.catch(error => {

@@ -33,0 +36,0 @@ request.errorHandler({ message: request.error || request.defaultError, error });

@@ -42,3 +42,4 @@ // @flow

flatMethod?: Function,
makeBody?: Function
makeBody?: Function,
schema?: Object
};

@@ -67,2 +68,3 @@

flatMethod: Function,
schema?: Object
};

@@ -69,0 +71,0 @@

Sorry, the diff of this file is not supported yet

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