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

mappersmith

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mappersmith - npm Package Compare versions

Comparing version 2.16.1 to 2.17.0

33

client-builder.js

@@ -35,2 +35,3 @@ 'use strict';

this.Promise = configs.Promise;
this.manifest = new _manifest2.default(manifest, configs);

@@ -63,20 +64,32 @@ this.GatewayClassFactory = GatewayClassFactory;

invokeMiddlewares: function invokeMiddlewares(resourceName, resourceMethod, initialRequest) {
var _this3 = this;
var middleware = this.manifest.createMiddleware({ resourceName: resourceName, resourceMethod: resourceMethod });
var finalRequest = middleware.reduce(function (request, middleware) {
return middleware.request(request);
}, initialRequest);
var GatewayClass = this.GatewayClassFactory();
var gatewayConfigs = this.manifest.gatewayConfigs;
var callGateway = function callGateway() {
return new GatewayClass(finalRequest, gatewayConfigs).call();
var chainRequestPhase = function chainRequestPhase(requestPromise, middleware) {
return requestPromise.then(function (request) {
return middleware.request(request);
}).then(function (request) {
return _this3.Promise.resolve(request);
});
};
var execute = middleware.reduce(function (next, middleware) {
var chainResponsePhase = function chainResponsePhase(next, middleware) {
return function () {
return middleware.response(next);
};
}, callGateway);
};
return execute();
return new this.Promise(function (resolve, reject) {
return middleware.reduce(chainRequestPhase, _this3.Promise.resolve(initialRequest)).then(function (finalRequest) {
var callGateway = function callGateway() {
return new GatewayClass(finalRequest, gatewayConfigs).call();
};
var execute = middleware.reduce(chainResponsePhase, callGateway);
return execute().then(function (response) {
return resolve(response);
});
}).catch(reject);
});
}

@@ -83,0 +96,0 @@ };

@@ -18,3 +18,3 @@ 'use strict';

/* global VERSION */
var version = exports.version = '2.16.1';
var version = exports.version = '2.17.0';

@@ -21,0 +21,0 @@ var configs = exports.configs = {

@@ -22,4 +22,4 @@ 'use strict';

*/
var BasicAuthMiddleware = function BasicAuthMiddleware(authConfig) {
return function () {
exports.default = function (authConfig) {
return function BasicAuthMiddleware() {
return {

@@ -33,4 +33,2 @@ request: function request(_request) {

};
};
exports.default = BasicAuthMiddleware;
};

@@ -12,6 +12,6 @@ 'use strict';

*/
var CsrfMiddleware = function CsrfMiddleware() {
exports.default = function () {
var cookieName = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 'csrfToken';
var headerName = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'x-csrf-token';
return function () {
return function CsrfMiddleware() {
return {

@@ -36,4 +36,2 @@ request: function request(_request) {

};
};
exports.default = CsrfMiddleware;
};

@@ -20,3 +20,3 @@ 'use strict';

*/
var GlobalErrorHandler = function GlobalErrorHandler() {
var GlobalErrorHandlerMiddleware = function GlobalErrorHandlerMiddleware() {
return {

@@ -37,2 +37,2 @@ response: function response(next) {

exports.default = GlobalErrorHandler;
exports.default = GlobalErrorHandlerMiddleware;

@@ -52,5 +52,3 @@ 'use strict';

*/
var RetryMiddleware = function RetryMiddleware() {
return (0, _v2.default)(retryConfigs)();
};
var RetryMiddleware = (0, _v2.default)(retryConfigs);

@@ -57,0 +55,0 @@ exports.default = RetryMiddleware;

@@ -49,5 +49,6 @@ 'use strict';

*/
};var RetryMiddleware = function RetryMiddleware() {
};
exports.default = function () {
var customConfigs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
return function () {
return function RetryMiddleware() {
return {

@@ -74,5 +75,2 @@ request: function request(_request) {

exports.default = RetryMiddleware;
var retriableRequest = function retriableRequest(resolve, reject, next) {

@@ -79,0 +77,0 @@ var retry = function retry(retryTime, retryCount, retryConfigs) {

@@ -6,2 +6,3 @@ "use strict";

});
/**

@@ -19,4 +20,4 @@ * Automatically configure your requests with a default timeout

*/
var TimeoutMiddleware = function TimeoutMiddleware(timeoutValue) {
return function () {
exports.default = function (timeoutValue) {
return function TimeoutMiddleware() {
return {

@@ -30,4 +31,2 @@ request: function request(_request) {

};
};
exports.default = TimeoutMiddleware;
};
{
"name": "mappersmith",
"version": "2.16.1",
"version": "2.17.0",
"description": "It is a lightweight rest client for node.js and the browser",

@@ -5,0 +5,0 @@ "author": "Tulio Ornelas <ornelas.tulio@gmail.com>",

@@ -381,2 +381,16 @@ [![npm version](https://badge.fury.io/js/mappersmith.svg)](http://badge.fury.io/js/mappersmith)

__NOTE__: The request phase can be asynchronous, just return a promise resolving a request. Example:
```javascript
const MyMiddleware = () => ({
request(request) {
return Promise.resolve(
request.enhance({
headers: { 'x-special-token': 'abc123' }
})
)
}
})
```
### <a name="global-middleware"></a> Global middleware

@@ -383,0 +397,0 @@

@@ -20,3 +20,3 @@ 'use strict';

var _mappersmith = require('./mappersmith');
var _index = require('./index');

@@ -67,4 +67,4 @@ var _utils = require('./utils');

var install = exports.install = function install() {
originalGateway = _mappersmith.configs.gateway;
_mappersmith.configs.gateway = _mock2.default;
originalGateway = _index.configs.gateway;
_index.configs.gateway = _mock2.default;
};

@@ -78,3 +78,3 @@

if (originalGateway) {
_mappersmith.configs.gateway = originalGateway;
_index.configs.gateway = originalGateway;
originalGateway = null;

@@ -81,0 +81,0 @@ }

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