...

/

Solution: Adapt Configuration Sources

Solution: Adapt Configuration Sources

Unify environment, file, and remote configuration providers into one awaitable .get() interface.

We'll cover the following...

Solution explanation

  • Lines 2–6: We define an envProvider that reads environment variables.

    • It uses getValue(key) to return from process.env.

    • The method is synchronous but returns immediately.

  • Lines 9–14: We define a fileProvider that reads from a JSON object.

    • It uses a read(key) method that directly returns from its internal config.

    • Again, it’s synchronous.

  • Lines 17–26: We define a remoteProvider that simulates an async API.

    • It exposes fetch(key) ...