mappersmith
Advanced tools
Comparing version 2.0.0-rc7 to 2.0.0
@@ -50,3 +50,3 @@ 'use strict'; | ||
this.manifest.eachResource(function (name, methods) { | ||
client[name] = _this.buildResource(methods); | ||
client[name] = _this.buildResource(name, methods); | ||
}); | ||
@@ -56,3 +56,3 @@ | ||
}, | ||
buildResource: function buildResource(methods) { | ||
buildResource: function buildResource(resourceName, methods) { | ||
var _this2 = this; | ||
@@ -63,8 +63,8 @@ | ||
var request = new _request2.default(method.descriptor, requestParams); | ||
return _this2.invokeMiddlewares(request); | ||
return _this2.invokeMiddlewares(resourceName, method.name, request); | ||
})); | ||
}, {}); | ||
}, | ||
invokeMiddlewares: function invokeMiddlewares(initialRequest) { | ||
var middlewares = this.manifest.createMiddlewares(); | ||
invokeMiddlewares: function invokeMiddlewares(resourceName, resourceMethod, initialRequest) { | ||
var middlewares = this.manifest.createMiddlewares(resourceName, resourceMethod); | ||
var finalRequest = middlewares.reduce(function (request, middleware) { | ||
@@ -71,0 +71,0 @@ return middleware.request(request); |
@@ -57,3 +57,3 @@ 'use strict'; | ||
}, | ||
createMiddlewares: function createMiddlewares() { | ||
createMiddlewares: function createMiddlewares(resourceName, resourceMethod) { | ||
var createInstance = function createInstance(middlewareFactory) { | ||
@@ -67,3 +67,3 @@ return (0, _utils.assign)({ | ||
} | ||
}, middlewareFactory()); | ||
}, middlewareFactory({ resourceName: resourceName, resourceMethod: resourceMethod })); | ||
}; | ||
@@ -70,0 +70,0 @@ |
{ | ||
"name": "mappersmith", | ||
"version": "2.0.0-rc7", | ||
"version": "2.0.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>", |
@@ -287,2 +287,14 @@ [![npm version](https://badge.fury.io/js/mappersmith.svg)](http://badge.fury.io/js/mappersmith) | ||
It can, optionally, receive the `resourceName` and `resourceMethod`, example: | ||
```javascript | ||
const MyMiddleware = ({ resourceName, resourceMethod }) => ({ | ||
/* ... */ | ||
}) | ||
client.User.all() | ||
// resourceName: 'User' | ||
// resourceMethod: 'all' | ||
``` | ||
### Built-in middlewares | ||
@@ -289,0 +301,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
60076
0
568