mle-tools-configuration
Version:
A configuration management tool for TypeScript/JavaScript applications
107 lines (74 loc) โข 3.63 kB
Markdown
# mle-tools-configuration
[](https://www.npmjs.com/package/mle-tools-configuration)
[](https://opensource.org/licenses/MIT)
[](https://www.typescriptlang.org/)
[](https://github.com/mlefree/mle-tools-configuration/actions/workflows/ci.yml)
> A configuration management tool for TypeScript/JavaScript applications
## ๐ Features
- ๐ง Type-safe configuration management
- ๐ Dynamic configuration updates
- ๐ฏ Domain-based configuration organization
- ๐ JSON-based configuration storage
- ๐ฆ Easy integration with existing projects
- ๐ Comprehensive documentation with Memory Bank
## ๐ฆ Installation
```bash
npm install mle-tools-configuration
```
## ๐ฏ Quick Start
```typescript
import { Configuration, configurationFactory } from 'mle-tools-configuration';
// Set up initial configuration
configurationFactory.setUp(
[{ key: 'database', value: { host: 'localhost', port: 5432 } }],
[{ domain: 'app', keys: ['database'] }]
);
// Get configuration instance
const config = configurationFactory.getConfiguration();
// Access configuration values
const dbConfig = config.getSubConf('database');
console.log(dbConfig); // { host: 'localhost', port: 5432 }
// Merge new configuration
config.merge({
database: { username: 'admin' }
});
```
## ๐ Documentation
### Memory Bank
This project uses a Memory Bank for comprehensive documentation and context retention. The Memory Bank is located in the `.memory-bank` directory and contains the following files:
- `memory-bank-rules.md`: Rules to follow and to consider in all contexts
- `projectbrief.md`: Overview of the project, core requirements, and goals
- `productContext.md`: Why the project exists, problems it solves, and how it works
- `systemPatterns.md`: System architecture, key technical decisions, and design patterns
- `techContext.md`: Technologies used, development setup, and technical constraints
- `activeContext.md`: Current work focus, recent changes, and next steps
- `progress.md`: What works, what's left to build, and known issues
=> !! These files should always be considered as a context and keep up-to-date !!
## ๐ง API Reference
### Configuration Class
- `getJSON(domain?)`: Get the entire configuration as a JSON string
- `getSubJSON(key)`: Get a specific configuration section as a JSON string
- `getConf(domain?)`: Get the configuration object
- `getSubConf(key)`: Get a specific configuration section
- `contains(configurationAsString)`: Check if configuration contains the specified configuration
- `merge(conf)`: Merge new configuration
- `set(key, value)`: Set a specific configuration value
- `add(key, value)`: Add to existing configuration
- `update(factory)`: Update the configuration factory
### ConfigurationFactory
- `setUp(configs, domains)`: Initialize the configuration factory
- `getConfiguration(override?)`: Get a configuration instance
## ๐งช Testing
```bash
npm test
```
## ๐ Changelog
See [CHANGELOG.md](./CHANGELOG.md) for a detailed list of changes.
## ๐ License
This project is licensed under the MIT License - see the [LICENSE](./LICENSE) file for details.
## ๐ค Contributing
Contributions, issues, and feature requests are welcome! Feel free to check the issues page.
## ๐ Acknowledgments
- Built with TypeScript
- Tested with Mocha and Chai
- Coverage with NYC