npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

hygen-templates

v1.0.0

Published

Generadores Hygen para crear módulos NestJS con DDD y Clean Architecture

Readme

Hygen Templates

Librería de generadores Hygen para crear módulos NestJS con DDD y Clean Architecture de forma rápida y estandarizada.

🚀 Instalación

Opción 1: CLI Global (Recomendado)

npm install -g hygen-templates

Opción 2: Como dependencia local

npm install hygen-templates

📦 Uso

Con CLI Global

# Generar un módulo completo
hygen-templates module new --name=loans

# Ver ayuda
hygen-templates

Con dependencia local

Configuración en tu proyecto

Crea un archivo hygen.js en la raíz de tu proyecto:

module.exports = {
  templates: `${__dirname}/node_modules/hygen-templates/_templates`,
};

Generar un módulo completo

npx hygen module new --name=loans

Esto generará la siguiente estructura:

src/modules/loans/
├── domain/
│   ├── entities/
│   │   └── loan.entity.ts
│   └── repositories/
│       └── loan.repository.interface.ts
├── application/
│   └── use-cases/
│       └── create-loan.usecase.ts
├── infrastructure/
│   ├── repositories/
│   │   └── loan.repository.ts
│   └── mappers/
│       └── loan.mapper.ts
├── presentation/
│   ├── controllers/
│   │   └── loan.controller.ts
│   └── dtos/
│       └── create-loan.dto.ts
└── loan.module.ts

🏗️ Arquitectura Generada

Domain Layer

  • Entities: Entidades de dominio con TypeORM
  • Repositories: Interfaces de repositorio siguiendo el patrón Repository

Application Layer

  • Use Cases: Casos de uso que implementan la lógica de negocio

Infrastructure Layer

  • Repositories: Implementaciones concretas de los repositorios
  • Mappers: Conversores entre entidades y DTOs

Presentation Layer

  • Controllers: Controladores REST con endpoints CRUD básicos
  • DTOs: Objetos de transferencia de datos con validaciones

📝 Archivos Generados

Entidad Base

@Entity('loans')
export class LoanEntity {
  @PrimaryGeneratedColumn('uuid')
  id: string;

  @Column({ type: 'varchar', length: 255 })
  name: string;

  @Column({ type: 'text', nullable: true })
  description?: string;

  @Column({ type: 'boolean', default: true })
  isActive: boolean;

  @CreateDateColumn()
  createdAt: Date;

  @UpdateDateColumn()
  updatedAt: Date;
}

Use Case de Creación

@Injectable()
export class CreateLoanUseCase {
  constructor(
    private readonly loanRepository: ILoanRepository,
  ) {}

  async execute(createLoanDto: CreateLoanDto): Promise<LoanEntity> {
    const loan = await this.loanRepository.create({
      name: createLoanDto.name,
      description: createLoanDto.description,
      isActive: true,
    });

    return loan;
  }
}

Controller REST

@Controller('loans')
export class LoanController {
  @Post()
  @HttpCode(HttpStatus.CREATED)
  async create(@Body() createLoanDto: CreateLoanDto) {
    // Implementation
  }

  @Get()
  async findAll() {
    // Implementation
  }

  @Get(':id')
  async findOne(@Param('id') id: string) {
    // Implementation
  }

  @Put(':id')
  async update(@Param('id') id: string, @Body() updateLoanDto: Partial<CreateLoanDto>) {
    // Implementation
  }

  @Delete(':id')
  @HttpCode(HttpStatus.NO_CONTENT)
  async remove(@Param('id') id: string) {
    // Implementation
  }
}

🔧 Personalización

Los templates utilizan helpers de Hygen para adaptar los nombres dinámicamente:

  • h.changeCase.pascal(name): loanLoan
  • h.changeCase.camel(name): loanloan
  • h.changeCase.kebab(name): loanloan

🚀 Próximas Funcionalidades

  • Generador de Value Objects: npx hygen vo new --name=email
  • Generador de Repositorios: npx hygen repo new --name=user
  • Generador de Use Cases: npx hygen usecase new --name=approve-loan
  • Generador de DTOs: npx hygen dto new --name=update-user

🛠️ Desarrollo Local

Para contribuir al proyecto o probar cambios localmente:

# Clonar el repositorio
git clone https://github.com/fncordoba/hygen-templates.git
cd hygen-templates

# Instalar dependencias
npm install

# Instalar localmente para pruebas
npm link

# Probar el CLI
hygen-templates module new --name=test-module

# Desinstalar
npm unlink hygen-templates

📄 Licencia

MIT

🤝 Contribuir

  1. Fork el proyecto
  2. Crea una rama para tu feature (git checkout -b feature/AmazingFeature)
  3. Commit tus cambios (git commit -m 'Add some AmazingFeature')
  4. Push a la rama (git push origin feature/AmazingFeature)
  5. Abre un Pull Request

📞 Soporte

Si tienes alguna pregunta o necesitas ayuda, por favor abre un issue en GitHub.