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

nest-builder

v0.0.9

Published

πŸ”¨ Forge better NestJS modules with organized folder structure

Readme

nest-builder

πŸ”¨ A powerful CLI tool to forge NestJS modules with better folder organization and structure.

Installation

npm install -g nest-builder

Or with yarn:

yarn global add nest-builder

Quick Start

# Navigate to your NestJS project
cd my-nestjs-app

# Generate a complete resource
nest-builder resource users

# Or use the short alias
nb res users

Usage

Generate Complete Resource (Recommended)

nest-builder resource users
# or
nb res users

This creates a complete CRUD module with organized folder structure:

src/users/
β”œβ”€β”€ users.module.ts
β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ users.controller.ts
β”‚   └── users.controller.spec.ts
β”œβ”€β”€ services/
β”‚   β”œβ”€β”€ users.service.ts
β”‚   └── users.service.spec.ts
β”œβ”€β”€ dtos/
β”‚   β”œβ”€β”€ create-user.dto.ts
β”‚   └── update-user.dto.ts
└── entities/
    └── user.entity.ts

Generate Individual Components

# Generate only a controller
nest-builder controller users
nb co users

# Generate only a service
nest-builder service users
nb s users

# Generate only a module
nest-builder module users
nb mo users

Interactive Mode

Not sure what you need? Let the CLI guide you:

nest-builder resource
# Will ask for:
# - Module name
# - Transport layer (REST, GraphQL, etc.)
# - CRUD endpoints (yes/no)

Options

# Skip test files
nest-builder resource users --no-spec
nb res users --no-spec

# Generate empty controller/service (no CRUD)
nest-builder controller users --no-crud
nb service users --no-crud

All Available Commands

| Command | Alias | Description | |---------|-------|-------------| | nest-builder resource [name] | nb res | Generate complete module with all files | | nest-builder controller [name] | nb co | Generate controller only | | nest-builder service [name] | nb s | Generate service only | | nest-builder module [name] | nb mo | Generate module only | | nest-builder g <type> [name] | nb g | Generate using shorthand |

Shorthand Generate Commands

# Using the 'g' (generate) command
nest-builder g res users      # resource
nest-builder g co users       # controller
nest-builder g s users        # service
nest-builder g mo users       # module

Features

✨ Better Organization - Files organized in subfolders (controllers/, services/, dtos/, entities/)
πŸš€ Fast Generation - No compilation needed, instant file creation
🎯 Flexible - Generate complete resources or individual components
πŸ“ TypeScript Ready - All files are TypeScript with proper imports
πŸ§ͺ Testing Support - Generates spec files for testing (optional)
πŸ”§ Interactive Mode - CLI guides you through the options
πŸ“¦ Auto Import - Automatically updates app.module.ts

Examples

1. Generate a User Management Module

nest-builder resource users
# βœ” Creates complete CRUD structure
# βœ” Updates app.module.ts

2. Add Authentication Module

nest-builder resource auth --no-crud
# βœ” Creates module with empty controller/service
# βœ” Perfect for custom implementation

3. Generate Products with No Tests

nest-builder resource products --no-spec
# βœ” Skips .spec.ts files
# βœ” Faster for prototypes

4. Add a Controller to Existing Module

nest-builder controller orders
# βœ” Adds controller to existing orders module
# βœ” Module must exist first

Comparison with NestJS CLI

| Feature | NestJS CLI | nest-builder | |---------|------------|------------| | Command | nest g resource users | nest-builder resource users | | Folder Organization | Flat structure | Organized subfolders | | Speed | Requires compilation | Instant | | Interactive Mode | βœ“ | βœ“ | | CRUD Generation | βœ“ | βœ“ | | Custom Structure | βœ— | βœ“ |

Generated File Structure

With nest-builder (Organized):

src/users/
β”œβ”€β”€ users.module.ts
β”œβ”€β”€ controllers/
β”‚   └── users.controller.ts
β”œβ”€β”€ services/
β”‚   └── users.service.ts
β”œβ”€β”€ dtos/
β”‚   └── *.dto.ts
└── entities/
    └── *.entity.ts

With NestJS CLI (Flat):

src/users/
β”œβ”€β”€ users.module.ts
β”œβ”€β”€ users.controller.ts
β”œβ”€β”€ users.service.ts
β”œβ”€β”€ dto/
β”‚   └── *.dto.ts
└── entities/
    └── *.entity.ts

Requirements

  • Node.js >= 14.0.0
  • An existing NestJS project
  • Run from the root of your NestJS project

Installation & Setup Guide

# 1. Create your NestJS project (if you haven't)
nest new my-app
cd my-app

# 2. Install nest-builder globally
npm install -g nest-builder

# 3. Start generating modules!
nest-builder resource users
nest-builder resource products
nest-builder resource orders

# 4. Run your app
npm run start:dev

Tips & Best Practices

  1. Start with resources: Use nest-builder resource for new features
  2. Use singular names: The CLI will pluralize when needed
  3. Follow NestJS conventions: Use kebab-case for file names
  4. Generate tests: Keep --spec enabled for production code
  5. Interactive mode for beginners: Just run nest-builder resource without arguments

Troubleshooting

"Not in a NestJS project"

  • Make sure you're in the root directory of your NestJS project
  • Check that package.json contains @nestjs/core

"Module already exists"

  • The module folder already exists
  • Use individual generators to add components

"Cannot find app.module.ts"

  • Ensure src/app.module.ts exists
  • The tool expects standard NestJS structure

Contributing

Found a bug or want a feature? Contributions are welcome!

  1. Fork the repository
  2. Create your feature branch
  3. Commit your changes
  4. Push to the branch
  5. Open a Pull Request

License

MIT

Author

Built with ❀️ for NestJS developers who value their time and clean code architecture.


Note: This tool complements the official NestJS CLI. Use nest for project creation and nest-builder for better module generation.