nestjs-frameworklisted
Install: claude install-skill FortiumPartners/ensemble
# NestJS Framework Skill
## Quick Reference
**When to Use**: Building scalable Node.js/TypeScript backend applications with modular architecture
**Core Strengths**: Dependency injection, modular design, enterprise patterns, comprehensive testing
**Target Coverage**: Services ≥80%, Controllers ≥70%, E2E ≥60%, Overall ≥75%
## Essential Patterns
### Module Architecture
```typescript
// users/users.module.ts
@Module({
imports: [TypeOrmModule.forFeature([User]), AuthModule],
controllers: [UserController],
providers: [
UserService,
UserRepository,
{ provide: 'USER_REPOSITORY', useClass: UserRepository },
],
exports: [UserService],
})
export class UsersModule {}
```
**Key Principles**:
- Clear module boundaries and responsibilities
- Export only what other modules need
- Import shared modules (AuthModule, DatabaseModule)
- Use token-based providers for abstraction
### Dependency Injection
```typescript
// users/services/user.service.ts
@Injectable()
export class UserService {
constructor(
@Inject('USER_REPOSITORY') private readonly userRepository: UserRepository,
private readonly hashingService: HashingService,
private readonly eventEmitter: EventEmitter2,
) {}
async createUser(dto: CreateUserDto): Promise<User> {
const hashedPassword = await this.hashingService.hash(dto.password);
const user = await this.userRepository.create({
...dto,
password: hashedPassword,
});
this.eventEmitter.emit('user.created',