Solution: Adapt Configuration Sources
Unify environment, file, and remote configuration providers into one awaitable .get() interface.
We'll cover the following...
We'll cover the following...
Solution explanation
Lines 2–6: We define an
envProviderthat reads environment variables.It uses
getValue(key)to return fromprocess.env.The method is synchronous but returns immediately.
Lines 9–14: We define a
fileProviderthat reads from a JSON object.It uses a
read(key)method that directly returns from its internalconfig.Again, it’s synchronous.
Lines 17–26: We define a
remoteProviderthat simulates an async API.It exposes
fetch(key)...