axios-middleware
Advanced tools
Comparing version 0.3.0 to 0.3.1
/** | ||
* axios-middleware v0.3.0 | ||
* axios-middleware v0.3.1 | ||
* (c) 2018 Émile Bergeron | ||
@@ -145,5 +145,5 @@ * @license MIT | ||
Service: HttpMiddlewareService, | ||
version: '0.3.0', | ||
version: '0.3.1', | ||
}; | ||
module.exports = index; |
/** | ||
* axios-middleware v0.3.0 | ||
* axios-middleware v0.3.1 | ||
* (c) 2018 Émile Bergeron | ||
@@ -143,3 +143,3 @@ * @license MIT | ||
Service: HttpMiddlewareService, | ||
version: '0.3.0', | ||
version: '0.3.1', | ||
}; | ||
@@ -146,0 +146,0 @@ |
/** | ||
* axios-middleware v0.3.0 | ||
* axios-middleware v0.3.1 | ||
* (c) 2018 Émile Bergeron | ||
@@ -149,3 +149,3 @@ * @license MIT | ||
Service: HttpMiddlewareService, | ||
version: '0.3.0', | ||
version: '0.3.1', | ||
}; | ||
@@ -152,0 +152,0 @@ |
/** | ||
* axios-middleware v0.3.0 | ||
* axios-middleware v0.3.1 | ||
* (c) 2018 Émile Bergeron | ||
* @license MIT | ||
*/ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AxiosMiddleware=e()}(this,function(){"use strict";var t=function(t){this.middlewares=[],this.setHttp(t)};return t.prototype.setHttp=function(t){var e=this;return this.unsetHttp(),t&&(this.http=t,this.originalAdapter=t.defaults.adapter,t.defaults.adapter=function(t){return e.adapter(t)}),this},t.prototype.unsetHttp=function(){return this.http&&(this.http.defaults.adapter=this.originalAdapter,this.http=null),this},t.prototype.has=function(t){return-1<this.middlewares.indexOf(t)},t.prototype.register=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){if(e.has(t))throw new Error("Middleware already registered");e.middlewares.push(t)}),this},t.prototype.unregister=function(t){var e=this.middlewares.indexOf(t);return-1<e&&this.middlewares.splice(e,1),this},t.prototype.reset=function(){return this.middlewares.length=0,this},t.prototype.adapter=function(t){var e=this,r=[function(t){return e._onSync(e.originalAdapter.call(e.http,t))},void 0],n=Promise.resolve(t);for(this.middlewares.forEach(function(e){r.unshift(e.onRequest&&function(t){return e.onRequest(t)},e.onRequestError&&function(t){return e.onRequestError(t)})}),this.middlewares.forEach(function(e){r.push(e.onResponse&&function(t){return e.onResponse(t)},e.onResponseError&&function(t){return e.onResponseError(t)})});r.length;)n=n.then(r.shift(),r.shift());return n},t.prototype._onSync=function(t){return this.middlewares.reduce(function(t,e){return e.onSync?e.onSync(t):t},t)},{Service:t,version:"0.3.0"}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.AxiosMiddleware=e()}(this,function(){"use strict";var t=function(t){this.middlewares=[],this.setHttp(t)};return t.prototype.setHttp=function(t){var e=this;return this.unsetHttp(),t&&(this.http=t,this.originalAdapter=t.defaults.adapter,t.defaults.adapter=function(t){return e.adapter(t)}),this},t.prototype.unsetHttp=function(){return this.http&&(this.http.defaults.adapter=this.originalAdapter,this.http=null),this},t.prototype.has=function(t){return-1<this.middlewares.indexOf(t)},t.prototype.register=function(t){var e=this;return Array.isArray(t)||(t=[t]),t.forEach(function(t){if(e.has(t))throw new Error("Middleware already registered");e.middlewares.push(t)}),this},t.prototype.unregister=function(t){var e=this.middlewares.indexOf(t);return-1<e&&this.middlewares.splice(e,1),this},t.prototype.reset=function(){return this.middlewares.length=0,this},t.prototype.adapter=function(t){var e=this,r=[function(t){return e._onSync(e.originalAdapter.call(e.http,t))},void 0],n=Promise.resolve(t);for(this.middlewares.forEach(function(e){r.unshift(e.onRequest&&function(t){return e.onRequest(t)},e.onRequestError&&function(t){return e.onRequestError(t)})}),this.middlewares.forEach(function(e){r.push(e.onResponse&&function(t){return e.onResponse(t)},e.onResponseError&&function(t){return e.onResponseError(t)})});r.length;)n=n.then(r.shift(),r.shift());return n},t.prototype._onSync=function(t){return this.middlewares.reduce(function(t,e){return e.onSync?e.onSync(t):t},t)},{Service:t,version:"0.3.1"}}); |
{ | ||
"name": "axios-middleware", | ||
"version": "0.3.0", | ||
"version": "0.3.1", | ||
"description": "Simple axios HTTP middleware service", | ||
@@ -5,0 +5,0 @@ "author": "Emile Bergeron <ber.emile@prismalstudio.com>", |
@@ -8,4 +8,2 @@ # axios-middleware | ||
Explore [**the documentation**](https://emileber.github.io/axios-middleware/). | ||
## Installation | ||
@@ -19,32 +17,2 @@ | ||
A simple example using the [simplified middleware syntax](https://emileber.github.io/axios-middleware/#/simplified-syntax). | ||
```javascript | ||
import axios from 'axios'; | ||
import { HttpMiddlewareService } from 'axios-middleware'; | ||
// Create a new service instance | ||
const service = new HttpMiddlewareService(axios); | ||
// Then register your middleware instances. | ||
service.register({ | ||
onRequest(config) { | ||
// handle the request config | ||
return config; | ||
}, | ||
onSync(promise) { | ||
// handle the promsie | ||
return promise; | ||
}, | ||
onResponse(response) { | ||
// handle the response | ||
return response; | ||
} | ||
}); | ||
// We're good to go! | ||
export default service; | ||
``` | ||
A common use-case would be to expose an instance of the service which consumes an _axios_ instance configured for an API. It's then possible to register middlewares for this API at different stages of the initialization process of an application. | ||
Explore [**the documentation**](https://emileber.github.io/axios-middleware/) or the `docs/` directory. |
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
17673
17