@temboplus/settings
v0.2.1
Published
Type-safe, validated, class-based configuration system for TemboPlus applications and modules.
Readme
temboplus-settings
Type-safe, validated, class-based configuration system for TemboPlus applications and modules.
Requirements
- Node.js v22.19.0+ (LTS recommended)
- npm v10.9.3+
- TypeScript v5.9.3+
- reflect-metadata v0.2.2+
- tslib v2.8.1+, for optimized bundles
Installation
npm install --save @temboplus/settingsUsage
1. Define Settings decorated classes
// src/settings/app.settings.ts
import { Settings } from '@temboplus/settings';
import { IsInt, Min } from 'class-validator';
import { Expose, Type } from 'class-transformer';
@Settings()
export class AppSettings {
@Expose({ name: 'APP_PORT' })
@IsInt()
@Max(65_535)
@Min(1)
@Type(() => Number)
port = 3000;
}2. Import SettingsModule into the Root Module (AppModule)
// app.module.ts
import { Module } from '@nestjs/common';
import { SettingsModule } from '@temboplus/settings';
@Module({
imports: [
SettingsModule.forRoot({
settings: [AppSettings /*, other settings */],
}), // Import once here
// ... other modules
],
})
export class AppModule {}3. Inject Settings into Services, Controllers etc.
// src/services/example.service.ts
import { Injectable } from '@nestjs/common';
import { AppSettings } from '../settings';
@Injectable()
export class ExampleService {
constructor(private readonly appSettings: AppSettings) {}
getPort(): number {
return this.appSettings.port;
}
// ... other methods
}For a complete reference of all available classes, methods, and modules, see the API Reference section.
Contribute
We welcome contributions! Here's how to get started:
How to Contribute
Open an Issue Start by opening an issue to discuss your proposed changes.
Clone the Repo
git clone [email protected]:TemboPlus-Inc/temboplus-settings.git cd temboplus-settingsInstall Dependencies
npm installCreate a Feature Branch
git checkout -b feature/<your-feature-name> mainMake Your Changes & Run Checks
npm run checkFor available scripts and automation workflows, see the Tasks guide.
Commit Your Changes
git commit -m "feat(<scope>): <add new feature description>"Push & Submit a Pull Request
git push origin feature/<your-feature-name>Then, open a Pull Request (PR) to the main branch.
Contribution Guidelines
- Follow SOLID principles to write clean, maintainable, and scalable code.
- Follow the GitFlow workflow branching model.
- Follow Conventional Commits (
feat,fix,chore, etc.). - Write meaningful commit messages, PR titles, and code comments.
- Ensure the code passes checks before submitting.
- Keep changes focused and well-scoped.
