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

rest-api-handler

Package Overview
Dependencies
Maintainers
1
Versions
69
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rest-api-handler - npm Package Compare versions

Comparing version 1.6.1 to 1.7.0

5

CHANGELOG.md

@@ -5,2 +5,7 @@ # Change Log

## [1.7.0] 2018-05-31
### Added
- Add urldecode format for requests body
## [1.6.1] 2018-04-20

@@ -7,0 +12,0 @@ ### Fixed

19

dist/Api.js

@@ -50,2 +50,8 @@ 'use strict';

/**
* @desc Url encoded data in body
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
*/
var URL_ENCODED_FORMAT = 'urlencoded';
var classCallCheck = function (instance, Constructor) {

@@ -308,3 +314,3 @@ if (!(instance instanceof Constructor)) {

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -327,3 +333,3 @@ return this.requestWithBody(namespace, 'POST', data, format);

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -348,3 +354,3 @@ return this.requestWithBody(namespace, 'PUT', data, format);

value: function convertData(data) {
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Api.FORMATS.JSON_FORMAT;
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : JSON_FORMAT;

@@ -360,2 +366,6 @@ if (to === FORM_DATA_FORMAT) {

if (to === URL_ENCODED_FORMAT) {
return Api.convertParametersToUrl(data).slice(1);
}
return JSON.stringify(data);

@@ -395,5 +405,6 @@ }

JSON_FORMAT: JSON_FORMAT,
FORM_DATA_FORMAT: FORM_DATA_FORMAT
FORM_DATA_FORMAT: FORM_DATA_FORMAT,
URL_ENCODED_FORMAT: URL_ENCODED_FORMAT
};
module.exports = Api;

@@ -19,3 +19,10 @@ 'use strict';

/**
* @desc Url encoded data in body
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
*/
var URL_ENCODED_FORMAT = 'urlencoded';
exports.JSON_FORMAT = JSON_FORMAT;
exports.FORM_DATA_FORMAT = FORM_DATA_FORMAT;
exports.URL_ENCODED_FORMAT = URL_ENCODED_FORMAT;

@@ -48,2 +48,8 @@ /**

/**
* @desc Url encoded data in body
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
*/
var URL_ENCODED_FORMAT = 'urlencoded';
var classCallCheck = function (instance, Constructor) {

@@ -330,3 +336,3 @@ if (!(instance instanceof Constructor)) {

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -349,3 +355,3 @@ return this.requestWithBody(namespace, 'POST', data, format);

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -370,3 +376,3 @@ return this.requestWithBody(namespace, 'PUT', data, format);

value: function convertData(data) {
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Api.FORMATS.JSON_FORMAT;
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : JSON_FORMAT;

@@ -382,2 +388,6 @@ if (to === FORM_DATA_FORMAT) {

if (to === URL_ENCODED_FORMAT) {
return Api.convertParametersToUrl(data).slice(1);
}
return JSON.stringify(data);

@@ -417,3 +427,4 @@ }

JSON_FORMAT: JSON_FORMAT,
FORM_DATA_FORMAT: FORM_DATA_FORMAT
FORM_DATA_FORMAT: FORM_DATA_FORMAT,
URL_ENCODED_FORMAT: URL_ENCODED_FORMAT
};

@@ -555,2 +566,2 @@

export { JSON_FORMAT, FORM_DATA_FORMAT, Api, responseProcessor as defaultResponseProcessor, DefaultResponseProcessor, DefaultApiException };
export { JSON_FORMAT, FORM_DATA_FORMAT, URL_ENCODED_FORMAT, Api, responseProcessor as defaultResponseProcessor, DefaultResponseProcessor, DefaultApiException };

@@ -52,2 +52,8 @@ 'use strict';

/**
* @desc Url encoded data in body
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
*/
var URL_ENCODED_FORMAT = 'urlencoded';
var classCallCheck = function (instance, Constructor) {

@@ -334,3 +340,3 @@ if (!(instance instanceof Constructor)) {

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -353,3 +359,3 @@ return this.requestWithBody(namespace, 'POST', data, format);

var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : Api.FORMATS.JSON_FORMAT;
var format = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : JSON_FORMAT;

@@ -374,3 +380,3 @@ return this.requestWithBody(namespace, 'PUT', data, format);

value: function convertData(data) {
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : Api.FORMATS.JSON_FORMAT;
var to = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : JSON_FORMAT;

@@ -386,2 +392,6 @@ if (to === FORM_DATA_FORMAT) {

if (to === URL_ENCODED_FORMAT) {
return Api.convertParametersToUrl(data).slice(1);
}
return JSON.stringify(data);

@@ -421,3 +431,4 @@ }

JSON_FORMAT: JSON_FORMAT,
FORM_DATA_FORMAT: FORM_DATA_FORMAT
FORM_DATA_FORMAT: FORM_DATA_FORMAT,
URL_ENCODED_FORMAT: URL_ENCODED_FORMAT
};

@@ -561,2 +572,3 @@

exports.FORM_DATA_FORMAT = FORM_DATA_FORMAT;
exports.URL_ENCODED_FORMAT = URL_ENCODED_FORMAT;
exports.Api = Api;

@@ -563,0 +575,0 @@ exports.defaultResponseProcessor = responseProcessor;

{
"name": "rest-api-handler",
"version": "1.6.1",
"version": "1.7.0",
"description": "Handler for REST APIs",

@@ -24,9 +24,9 @@ "main": "dist/index.js",

"devDependencies": {
"cross-fetch": "^2.1.0",
"@socifi/eslint-config": "^1.6.2",
"flow-bin": "0.70.0",
"@socifi/jest-config": "^1.4.0",
"@socifi/rollup-config": "^1.6.0",
"cross-fetch": "^2.2.0",
"flow-bin": "0.73.0",
"flow-coverage-report": "^0.5.0",
"flow-typed": "^2.4.0",
"@socifi/jest-config": "^1.4.0",
"@socifi/rollup-config": "^1.6.0"
"flow-typed": "^2.4.0"
},

@@ -33,0 +33,0 @@ "browserslist": [

// @flow
import resolveProcessors from './resolveProcessors';
import { JSON_FORMAT, FORM_DATA_FORMAT } from './dataFormats';
import { JSON_FORMAT, FORM_DATA_FORMAT, URL_ENCODED_FORMAT } from './dataFormats';
import type { Format } from './dataFormats';

@@ -47,2 +47,3 @@ import type { ProcessorAdapter } from './resolveProcessors';

FORM_DATA_FORMAT,
URL_ENCODED_FORMAT,
};

@@ -81,3 +82,3 @@

*/
static convertData(data: Object, to: ?Format = Api.FORMATS.JSON_FORMAT): string | FormData {
static convertData(data: Object, to: ?Format = JSON_FORMAT): string | FormData {
if (to === FORM_DATA_FORMAT) {

@@ -92,2 +93,6 @@ const formData = new FormData();

if (to === URL_ENCODED_FORMAT) {
return Api.convertParametersToUrl(data).slice(1);
}
return JSON.stringify(data);

@@ -248,3 +253,3 @@ }

*/
post(namespace: string, data: Object = {}, format: Format = Api.FORMATS.JSON_FORMAT): Promise<ProcessedResponse> {
post(namespace: string, data: Object = {}, format: Format = JSON_FORMAT): Promise<ProcessedResponse> {
return this.requestWithBody(namespace, 'POST', data, format);

@@ -261,3 +266,3 @@ }

*/
put(namespace: string, data: Object = {}, format: Format = Api.FORMATS.JSON_FORMAT): Promise<ProcessedResponse> {
put(namespace: string, data: Object = {}, format: Format = JSON_FORMAT): Promise<ProcessedResponse> {
return this.requestWithBody(namespace, 'PUT', data, format);

@@ -264,0 +269,0 @@ }

@@ -19,2 +19,8 @@ // @flow

export type Format = typeof JSON_FORMAT | typeof FORM_DATA_FORMAT;
/**
* @desc Url encoded data in body
* @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST
*/
export const URL_ENCODED_FORMAT: 'urlencoded' = 'urlencoded';
export type Format = typeof JSON_FORMAT | typeof FORM_DATA_FORMAT | typeof URL_ENCODED_FORMAT;
// @flow
import Api from './Api';
import defaultResponseProcessor from './responseProcessor';
import { JSON_FORMAT, FORM_DATA_FORMAT } from './dataFormats';
import { JSON_FORMAT, FORM_DATA_FORMAT, URL_ENCODED_FORMAT } from './dataFormats';
import DefaultResponseProcessor from './DefaultResponseProcessor';

@@ -13,2 +13,2 @@ import DefaultApiException from './DefaultApiException';

export type { ProcessedResponse, ApiResponseType, Format, ProcessorAdapter, ApiExceptionInterface };
export { JSON_FORMAT, FORM_DATA_FORMAT, Api, defaultResponseProcessor, DefaultResponseProcessor, DefaultApiException };
export { JSON_FORMAT, FORM_DATA_FORMAT, URL_ENCODED_FORMAT, Api, defaultResponseProcessor, DefaultResponseProcessor, DefaultApiException };

Sorry, the diff of this file is not supported yet

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