@nodescript/config
v1.1.0
Published
Declarative configuration microframework
Downloads
6
Keywords
Readme
Configuration Microframework
Declarative configuration framework for Mesh IoC.
Highlights
- 🔥 Zero dependencies
- 🗜 Tidy and compact
- 💻 Works in browser
- 🔬 Strongly typed and introspectable
- 🌳 Ergonomic
Usage
- Define and use configs in your classes:
export class MyDatabase {
@config() DATABASE_USERNAME!: string;
@config() DATABASE_PASSWORD!: string;
@config({ default: 10 }) DATABASE_MAX_CONNECTIONS!: number;
async connect() {
await this.db.connect({
username: this.DATABASE_USERNAME,
password: this.DATABASE_PASSWORD,
maxConnections: this.DATABASE_MAX_CONNECTIONS,
});
}
}
- Define
Config
provider in Mesh:
mesh.service(MyDatabase);
mesh.service(Config, ProcessEnvConfig);
Now
DATABASE_*
values will be read fromprocess.env
.Enjoy!