Skip to content

MeshIoC/mesh-config

Repository files navigation

Configuration Microframework

Declarative configuration microframework for Mesh IoC.

Highlights

  • 🗜 Tidy and compact
  • 💻 Works in browser
  • 🔬 Strongly typed and introspectable
  • 🌳 Ergonomic

Usage

  1. 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,
        });
    }
}
  1. Define Config provider in Mesh:
mesh.service(MyDatabase);
mesh.service(Config, ProcessEnvConfig);
  1. Now DATABASE_* values will be read from process.env.

  2. Enjoy!

About

Configuration microframework for Mesh IoC

Resources

Stars

Watchers

Forks

Packages

No packages published