Implement DNS Caching with cacheable-lookup

This commit is contained in:
Simon Caron
2023-12-10 14:33:39 -05:00
parent 0beb42194d
commit 5bcf8ae51a
3 changed files with 22 additions and 9 deletions

View File

@@ -1,17 +1,20 @@
const axios = require("axios");
const https = require('https');
const CacheableLookup = require('cacheable-lookup');
const cacheable = new CacheableLookup();
const agent = new https.Agent({
rejectUnauthorized: (process.env.REJECT_SELF_SIGNED_CERTIFICATES || 'true').toLowerCase() ==='true'
});
rejectUnauthorized: (process.env.REJECT_SELF_SIGNED_CERTIFICATES || 'true').toLowerCase() === 'true'
});
cacheable.install(agent);
const axios_instance = axios.create({
httpsAgent: agent
});
httpsAgent: agent
});
module.exports =
{
axios:axios_instance
};
module.exports =
{
axios: axios_instance
};

9
package-lock.json generated
View File

@@ -20,6 +20,7 @@
"axios": "^1.5.1",
"axios-cache-interceptor": "^1.3.1",
"bootstrap": "^5.2.3",
"cacheable-lookup": "^7.0.0",
"compare-versions": "^6.0.0-rc.1",
"compression": "^1.7.4",
"config": "^3.3.9",
@@ -7346,6 +7347,14 @@
"resolved": "https://registry.npmjs.org/cache-parser/-/cache-parser-1.2.4.tgz",
"integrity": "sha512-O0KwuHuJnbHUrghHi2kGp0SxnWSIBXTYt7M8WVhW0kbPRUNUKoE/Of6e1rRD6AAxmfxFunKnt90yEK09D+sc5g=="
},
"node_modules/cacheable-lookup": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/cacheable-lookup/-/cacheable-lookup-7.0.0.tgz",
"integrity": "sha512-+qJyx4xiKra8mZrcwhjMRMUhD5NR1R8esPkzIYxX96JiecFoxAXFuz/GpR3+ev4PE1WamHip78wV0vcmPQtp8w==",
"engines": {
"node": ">=14.16"
}
},
"node_modules/call-bind": {
"version": "1.0.5",
"resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.5.tgz",

View File

@@ -26,6 +26,7 @@
"axios": "^1.5.1",
"axios-cache-interceptor": "^1.3.1",
"bootstrap": "^5.2.3",
"cacheable-lookup": "^7.0.0",
"compare-versions": "^6.0.0-rc.1",
"compression": "^1.7.4",
"config": "^3.3.9",