cacheable-request
Advanced tools
Comparing version 6.0.0 to 6.1.0
{ | ||
"name": "cacheable-request", | ||
"version": "6.0.0", | ||
"version": "6.1.0", | ||
"description": "Wrap native HTTP requests with RFC compliant cache support", | ||
@@ -33,7 +33,7 @@ "license": "MIT", | ||
"clone-response": "^1.0.2", | ||
"get-stream": "^4.0.0", | ||
"get-stream": "^5.1.0", | ||
"http-cache-semantics": "^4.0.0", | ||
"keyv": "^3.0.0", | ||
"lowercase-keys": "^1.0.1", | ||
"normalize-url": "^3.1.0", | ||
"lowercase-keys": "^2.0.0", | ||
"normalize-url": "^4.1.0", | ||
"responselike": "^1.0.2" | ||
@@ -43,12 +43,12 @@ }, | ||
"@keyv/sqlite": "^2.0.0", | ||
"ava": "^0.25.0", | ||
"ava": "^1.1.0", | ||
"coveralls": "^3.0.0", | ||
"create-test-server": "2.1.1", | ||
"create-test-server": "3.0.0", | ||
"delay": "^4.0.0", | ||
"eslint-config-xo-lukechilds": "^1.0.0", | ||
"nyc": "^13.0.1", | ||
"nyc": "^14.1.1", | ||
"pify": "^4.0.0", | ||
"sqlite3": "^4.0.2", | ||
"this": "^1.0.2", | ||
"xo": "^0.22.0" | ||
"xo": "^0.23.0" | ||
}, | ||
@@ -55,0 +55,0 @@ "xo": { |
@@ -44,2 +44,3 @@ 'use strict'; | ||
} | ||
opts = { | ||
@@ -61,3 +62,4 @@ headers: {}, | ||
stripWWW: false, | ||
removeTrailingSlash: false | ||
removeTrailingSlash: false, | ||
stripAuthentication: false | ||
} | ||
@@ -76,4 +78,6 @@ ); | ||
requestErrorCallback = () => { | ||
requestErrored = true; | ||
resolve(); | ||
if (!requestErrored) { | ||
requestErrored = true; | ||
resolve(); | ||
} | ||
}; | ||
@@ -131,4 +135,4 @@ }); | ||
await this.cache.set(key, value, ttl); | ||
} catch (err) { | ||
ee.emit('error', new CacheableRequest.CacheError(err)); | ||
} catch (error) { | ||
ee.emit('error', new CacheableRequest.CacheError(error)); | ||
} | ||
@@ -140,4 +144,4 @@ })(); | ||
await this.cache.delete(key); | ||
} catch (err) { | ||
ee.emit('error', new CacheableRequest.CacheError(err)); | ||
} catch (error) { | ||
ee.emit('error', new CacheableRequest.CacheError(error)); | ||
} | ||
@@ -158,4 +162,4 @@ })(); | ||
ee.emit('request', req); | ||
} catch (err) { | ||
ee.emit('error', new CacheableRequest.RequestError(err)); | ||
} catch (error) { | ||
ee.emit('error', new CacheableRequest.RequestError(error)); | ||
} | ||
@@ -191,11 +195,14 @@ }; | ||
this.cache.on('error', err => ee.emit('error', new CacheableRequest.CacheError(err))); | ||
const errorHandler = error => ee.emit('error', new CacheableRequest.CacheError(error)); | ||
this.cache.once('error', errorHandler); | ||
ee.on('response', () => this.cache.removeListener('error', errorHandler)); | ||
try { | ||
await get(opts); | ||
} catch (err) { | ||
} catch (error) { | ||
if (opts.automaticFailover && !madeRequest) { | ||
makeRequest(opts); | ||
} | ||
ee.emit('error', new CacheableRequest.CacheError(err)); | ||
ee.emit('error', new CacheableRequest.CacheError(error)); | ||
} | ||
@@ -236,6 +243,6 @@ })(); | ||
CacheableRequest.RequestError = class extends Error { | ||
constructor(err) { | ||
super(err.message); | ||
constructor(error) { | ||
super(error.message); | ||
this.name = 'RequestError'; | ||
Object.assign(this, err); | ||
Object.assign(this, error); | ||
} | ||
@@ -245,6 +252,6 @@ }; | ||
CacheableRequest.CacheError = class extends Error { | ||
constructor(err) { | ||
super(err.message); | ||
constructor(error) { | ||
super(error.message); | ||
this.name = 'CacheError'; | ||
Object.assign(this, err); | ||
Object.assign(this, error); | ||
} | ||
@@ -251,0 +258,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
16750
217
+ Addedget-stream@5.2.0(transitive)
+ Addedlowercase-keys@2.0.0(transitive)
+ Addednormalize-url@4.5.1(transitive)
- Removedget-stream@4.1.0(transitive)
- Removednormalize-url@3.3.0(transitive)
Updatedget-stream@^5.1.0
Updatedlowercase-keys@^2.0.0
Updatednormalize-url@^4.1.0