Comments (7)
You can't.
from cacheable-lookup.
I think we should open an issue on Node.js then about adding an API to officially allow intercepting http.get
calls. There are lots of use-cases for that, including caching, debugging, etc.
from cacheable-lookup.
If shimmer
mocks the require
function, then you're good. Just remember to import got
after mocking http
.
Anyway I don't like that approach - it's too much hassle. Why don't you use something simpler, for example Got hooks? I mean the beforeRequest
hook. You can change the options too.
from cacheable-lookup.
My point is, how to leverage the functionality on this library into the http underlayer without using an explicit require or involve a dependency that integrates this library?
from cacheable-lookup.
I agree it could be useful to be able to globally inject this, as long as it's clearly documented it should not be done in reusable packages.
Something like:
const CacheableLookup = require('cacheable-lookup');
CacheableLookup.initGlobally();
Where initGlobally()
would accept the same options as an instance.
from cacheable-lookup.
from cacheable-lookup.
We cannot patch the http
module, but we can override the global Agent.
from cacheable-lookup.
Related Issues (20)
- Fallback fails when one family returns ENOENT HOT 1
- TS error when using QuickLRU from readme example HOT 5
- Querying for family=6 when family=4 is explicitly requested? HOT 3
- Question: How is DNS resolved? HOT 2
- DNS lookup are not cached HOT 3
- TS incompatibility between CacheableLookup.lookup and @types/node LookupFunction HOT 2
- round-robin dns support HOT 2
- Jest reporting CachableLookup is preventing shutdown HOT 3
- Ability to set minTtl? HOT 1
- Add stats to see how many calls were cached HOT 1
- Can you obtain the local hosts first and then use resolve4 or resolve6 HOT 5
- dns lookup is not cached the way I understand HOT 1
- Cacheable lookup responds with ESERVFAIL while native dns.resolve works HOT 10
- Enable tests again
- http2 & cacheable-lookup HOT 1
- Source isn't returned in Entry object HOT 1
- No way to dispose and timeout problems HOT 1
- Prefetch before expiration
- dnsCache.lookup types might be wrong? HOT 1
- Is there a version which supports CJS ? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cacheable-lookup.