@contextjs/configuration
Version:
Lightweight configuration system for ContextJS applications, featuring async providers and environment variable support.
50 lines (36 loc) • 1.61 kB
Markdown
[](https://github.com/contextjs/context/actions/workflows/tests.yaml)
[](https://www.npmjs.com/package/@contextjs/configuration)
[](https://github.com/contextjs/context/blob/main/LICENSE)
> Lightweight configuration system for ContextJS applications, featuring async providers and environment variable support.
- Fluent API for configuring providers
- Async-based configuration loading
- Support for environment variables
- Pluggable provider model
- Seamless integration with `Application` via `.useConfiguration()`
```bash
npm i @contextjs/configuration
```
```ts
import { Application } from "@contextjs/system";
import "@contextjs/configuration";
const app = new Application();
app.useConfiguration(options => {
options.useEnvironmentVariables();
options.useProvider({
async getValueAsync(key) {
if (key === "App:Port")
return 3000;
return null;
}
});
});
const port = await app.configuration.getValueAsync("App:Port");
```
For detailed API documentation, please refer to the [API Reference](https://contextjs.dev/api/configuration#api-reference).
All features are covered by 100% unit test coverage, ensuring reliability, correctness, and long-term maintainability - so you can focus on building, not debugging.