cacheable-request
Advanced tools
Comparing version 0.5.0 to 1.0.0
{ | ||
"name": "cacheable-request", | ||
"version": "0.5.0", | ||
"version": "1.0.0", | ||
"description": "Wrap native HTTP requests with RFC compliant cache support", | ||
@@ -39,3 +39,3 @@ "main": "src/index.js", | ||
"http-cache-semantics": "^3.7.3", | ||
"keyv": "^1.0.4", | ||
"keyv": "^2.0.1", | ||
"lowercase-keys": "^1.0.0", | ||
@@ -46,2 +46,3 @@ "normalize-url": "^1.9.1", | ||
"devDependencies": { | ||
"@keyv/sqlite": "^1.2.6", | ||
"ava": "^0.21.0", | ||
@@ -53,3 +54,2 @@ "coveralls": "^2.13.1", | ||
"get-stream": "^3.0.0", | ||
"keyv-sqlite": "^1.2.4", | ||
"nyc": "^11.0.2", | ||
@@ -56,0 +56,0 @@ "pify": "^3.0.0", |
@@ -11,2 +11,4 @@ # cacheable-request | ||
**Note:** This is a low level wrapper around the core HTTP modules, it's not a high level request library. | ||
## Install | ||
@@ -13,0 +15,0 @@ |
@@ -123,4 +123,42 @@ import EventEmitter from 'events'; | ||
test.cb('cacheableRequest emits error event if cache.delete errors', t => { | ||
const errMessage = 'Fail'; | ||
const store = new Map(); | ||
const cache = { | ||
get: store.get.bind(store), | ||
set: store.set.bind(store), | ||
delete: () => { | ||
throw new Error(errMessage); | ||
} | ||
}; | ||
const cacheableRequest = new CacheableRequest(request, cache); | ||
(async () => { | ||
let i = 0; | ||
const s = await createTestServer(); | ||
s.get('/', (req, res) => { | ||
const cc = i === 0 ? 'public, max-age=0' : 'public, no-cache, no-store'; | ||
i++; | ||
res.setHeader('Cache-Control', cc); | ||
res.end('hi'); | ||
}); | ||
await s.listen(s.port); | ||
cacheableRequest(s.url, () => { | ||
// This needs to happen in next tick so cache entry has time to be stored | ||
setImmediate(() => { | ||
cacheableRequest(s.url) | ||
.on('error', async err => { | ||
t.is(err.message, errMessage); | ||
await s.close(); | ||
t.end(); | ||
}) | ||
.on('request', req => req.end()); | ||
}); | ||
}).on('request', req => req.end()); | ||
})(); | ||
}); | ||
test.after('cleanup', async () => { | ||
await s.close(); | ||
}); |
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
28811
542
1
158
+ Addedkeyv@2.0.2(transitive)
- Removedkeyv@1.0.5(transitive)
Updatedkeyv@^2.0.1