Configuru is a library for configuration management. It is JSON/JSONC configuration loader and a clone project of AckeeCZ/configuru tool built for Node.js apps.
Getting started
- Install
- Create
.env.jsoncin root of your project, add defaults or placeholders.
{
// Database secrets
"PASSWORD": "testtest",
// Sever secrets
"SERVER_HOST": "localhost",
"SERVER_PORT": 3000,
// Entities
"CUSTOMER": "{\"age\": 25, \"email\":\"test@example.org\"}" // customer related secrets
}
-
(optional) As a developer (or environment), create a custom override file (e.g.
~/.env/my-project.jsonc) and save the path in yourCFG_JSON_PATH. -
Usage
// Import dependencies
use Deserialize;
use ;
use serde_json;
// Define data structures you want to load from configuration file. Data types must match variables in configuration file.
// Implement a conversion from Loader to your Config
- Use your configuration params throughout your app
License
This project is licensed under MIT.