I wrote a small Node.js API wrapper library (type=module) with several exported methods that all use the same fetcher method internally for actually calling the API. Currently the fetcher method takes URL host and basic auth username and password from the process.env variables, so any project that uses the library has to define these env variables somehow.
However, this setup has the limitation that you can only work on one environment at a time. Now I want to write a Node.js application that connects to both dev and prod environments so I need a way to config these three parameters before calling the methods. I wanted to write a class that takes these as parameters (so as state) from which the same API wrapper methods are available but obviously the fetcher should then use these values instead of the environment loaded variables. So I'm looking for a way for the fetcher method to access this info without having to pass them through every API method as extra parameters (which would also change/break the signature for the "default use case").
Anyone knows how to deal with this?