Socket
Socket
Sign inDemoInstall

cacheable-request

Package Overview
Dependencies
Maintainers
1
Versions
61
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cacheable-request - npm Package Compare versions

Comparing version 0.5.0 to 1.0.0

6

package.json
{
"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();
});
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