A collection of high-quality, reusable NestJS libraries published under the @future.ai organization. Currently focused on type-safe configuration management for enterprise NestJS applications.
Package | Version | Description |
---|---|---|
@future.ai/config | 0.2.1 | Type-safe configuration management for NestJS applications |
Our flagship package provides enterprise-grade configuration management:
- 🔒 Complete Type Safety: Full TypeScript support with intelligent autocomplete
- 🏗️ Flexible Registry: Register configurations with custom keys and types
- 🔍 Path-based Access: Access nested configuration values using dot notation
- 🌍 Global Module: Optional global configuration service
- ⚡ High Performance: Cached configuration values for fast access
- 🧪 Testable: Easy to mock and test configuration values
// Define your configurations
export const CONFIG_REGISTRY = {
base: defineConfig('base', () => ({
PORT: process.env.PORT || "3000",
})),
database: defineConfig('database', () => ({
HOST: process.env.DB_HOST,
PORT: parseInt(process.env.DB_PORT || "5432"),
}))
} as const;
// Register in your app
@Module({
imports: [ConfigModule.forRoot({ registry: CONFIG_REGISTRY })]
})
export class AppModule {}
// Use with full type safety
@Injectable()
export class DatabaseService {
constructor(
private configService: ConfigService<typeof CONFIG_REGISTRY>
) {}
connect() {
const host = this.configService.get('database.HOST'); // ✅ Type-safe!
const port = this.configService.get('database.PORT'); // ✅ Autocomplete works!
}
}
- Node.js >= 20
- pnpm >= 8
# Clone the repository
git clone https://github.com/future-ai/nestjs-libs.git
cd future-ai-libs
# Install dependencies
pnpm install
# Bootstrap packages
pnpm run bootstrap
# Build all packages
pnpm run build
# Run tests
pnpm test
# Lint code
pnpm run lint
# Format code
pnpm run format
npm install @future.ai/config
# or
pnpm add @future.ai/config
# or
yarn add @future.ai/config
See the full documentation for complete setup and usage instructions.
Use the provided script to create a new package:
./scripts/create-package.sh my-new-package
This will create a new package with:
- TypeScript configuration
- Jest testing setup
- Build scripts
- Package.json configured for @future.ai organization
To build all packages:
pnpm run build
To build a specific package:
cd packages/config
pnpm run build
Run all tests:
pnpm test
Run tests for a specific package:
cd packages/config
pnpm test
Before publishing, ensure you're logged into npm with access to the @future.ai organization:
pnpm login
To publish all changed packages:
pnpm run publish:all
This will automatically:
- Detect changed packages since last release
- Generate version numbers based on conventional commits
- Build packages
- Publish to npm
- Create git tags
- No manual confirmation required (fully automated)
future-ai-libs/
├── packages/ # All library packages
│ └── config/ # Type-safe configuration management
│ ├── src/ # Source code
│ │ ├── config.module.ts # NestJS dynamic module
│ │ ├── config.service.ts # Configuration service
│ │ ├── config.factory.ts # Factory functions
│ │ ├── config.type.ts # TypeScript types
│ │ └── index.ts # Exports
│ ├── test/ # Comprehensive tests
│ └── package.json # Package configuration
├── scripts/ # Build and utility scripts
├── lerna.json # Lerna configuration (fully automated)
├── package.json # Root package.json with workspaces
├── tsconfig.json # Root TypeScript configuration
└── jest.config.js # Root Jest configuration
- Create a new branch for your feature
- Make your changes
- Write/update tests
- Run
pnpm test
andpnpm run lint
- Submit a pull request
MIT © Future AI