25.0.0-beta.3 • Published 6 months ago
@contextjs/configuration-json v25.0.0-beta.3
@contextjs/configuration-json
JSON-based configuration provider for ContextJS applications.
Features
- Plug-and-play JSON configuration support
- Supports environment-specific configuration files
- Fully integrated with
@contextjs/configuration - Simple fluent API for loading files
Installation
npm i @contextjs/configuration-jsonQuick Start
Example json configuration file appsettings.json:
{
"App": {
"Port": 3000,
"Name": "My Application"
}
}Code:
import "@contextjs/configuration";
import "@contextjs/configuration-json";
import { Application, EnvironmentName } from "@contextjs/system";
const application = new Application();
application.useConfiguration(options => {
options.useJsonConfiguration(json => {
json.useFile("filepath/appsettings.json");
json.useFile("filepath/appsettings.development.json", "development");
json.useFile("filepath/appsettings.production.json", "production");
});
});
application.environment.name = EnvironmentName.production;
const port = await application.configuration.getValueAsync("App:Port");
console.log(`Starting server on port ${port}...`);API Reference
For detailed API documentation, please refer to the API Reference.
25.0.0-beta.3
6 months ago
25.0.0-beta.2
6 months ago
25.0.0-beta.1
6 months ago
0.5.3-alpha.1
6 months ago
0.5.2-alpha.1
6 months ago
0.5.1-alpha.1
7 months ago
0.5.0-alpha.1
7 months ago
0.4.8
7 months ago
0.4.7
8 months ago
0.4.6
8 months ago
0.4.5
8 months ago
0.4.4
8 months ago
0.4.3
8 months ago
0.4.2
8 months ago
0.4.1
8 months ago
0.4.0
8 months ago