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 πŸ™

Β© 2025 – Pkg Stats / Ryan Hefner

nodejs-boiler

v1.0.0

Published

πŸš€ A fast, modern, and production-ready Node.js project boilerplate generator CLI. Quickly scaffold a full-featured Express.js application with authentication, database setup, API structure, and best practices.

Readme

npm version License: MIT PRs Welcome

πŸš€ Node.js Boilerplate Generator

A powerful CLI tool to instantly generate production-ready Node.js applications with MongoDB integration. This boilerplate is designed to kickstart your backend development with best practices, security, and scalability in mind.

🎯 Why This Project?

Building a new Node.js project from scratch involves repetitive setup tasks, configuration, and boilerplate code. This project aims to:

  • Save Development Time: Eliminate days of initial setup and configuration
  • Enforce Best Practices: Follows industry standards for security, performance, and maintainability
  • Scalable Architecture: Built with scalability and maintainability in mind
  • Database Flexibility: Seamlessly switch between MongoDB and SQL databases
  • Production Ready: Includes essential features like authentication, error handling, and logging

✨ Features

Core Features

  • πŸ—οΈ One-command project generation - Get started in seconds
  • πŸš€ Express.js with modern ES modules (ESM)
  • πŸ”’ JWT Authentication with role-based access control
  • πŸ› οΈ Environment-based configuration
  • πŸ“ API documentation with Swagger/OpenAPI

πŸ—„οΈ MongoDB Features

  • Mongoose ODM for elegant MongoDB object modeling
  • Schema Validation - Enforce data integrity
  • Middleware Support - Pre/post hooks for business logic
  • Connection Pooling - Optimized database connections
  • Transaction Support - ACID transactions
  • Indexing - Optimized query performance
  • Aggregation Pipeline - Powerful data processing

SQL Features

  • Sequelize ORM for SQL databases
  • Support for PostgreSQL, MySQL, SQLite, MSSQL
  • Database migrations and seeders
  • Connection pooling and transactions

πŸš€ Getting Started

Prerequisites

  • Node.js 16.x or higher
  • npm 6.x or higher

Step 1: Install the Boilerplate

Choose one of the following methods:

Method 1: Using npx (Recommended)

# Create a new project
npx nodejs-boiler

Method 2: Global Installation

# Install globally
npm install -g nodejs-boiler

# Create new project
nodejs-boiler

Step 2: Verify Installation

  1. Start your application:

    # Development mode with hot-reload
    npm run dev
    
    # Or production mode
    npm start

βš™οΈ Project configuration

1. Environment Configuration

Create a .env.example file in your project root.

2. Database Connection

Your application automatically connects to database on startup. The connection is managed in src/db folder.

3. Verify the Connection

  1. Check the console for successful MongoDB connection message
  2. Check the Api working Visit http://localhost:8080/
  3. Visit http://localhost:8080/health for API health status
  4. Access Swagger docs at http://localhost:8080/api/docs

Quick Start

# Using npx (recommended)
npx nodejs-boiler@latest

# Or install globally
npm install -g nodejs-boiler
nodejs-boiler

# Select a folder:
❯ New directory
  Current directory

# Project folder Name:
(nodejs_boiler-app) or your_folder_name

# Select a database:
❯ mongodb
  postgresql

# Install dependencies
npm install

# Set up environment variables
cp .env.example .env

# Start development server
npm run dev

Key Features of the User Model:

  • Schema Validation: Built-in validation for all fields
  • Password Hashing: Automatic password hashing before save
  • Security: Passwords are not returned by default
  • Timestamps: Automatic createdAt and updatedAt fields
  • Role-based Access: User roles with 'user' and 'admin' options

Project Structure πŸ“‚

project-root/
β”œβ”€β”€ docs/
β”‚   └── swagger.json              # All apis swagger json files
|
β”œβ”€β”€ logs/                         # Documentation Folder
|
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ configs/                  # Configuration files
β”‚   β”‚   └── envConfig.js          # Application configurations
β”‚   β”‚
β”‚   β”œβ”€β”€ controllers/              # Route controllers
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── user.controller.js
β”‚   β”‚
β”‚   β”œβ”€β”€ db/                       # Database configuration
β”‚   β”‚
β”‚   β”œβ”€β”€ helpers/                  # Helper functions
β”‚   β”‚   β”œβ”€β”€ logger.js
β”‚   β”‚   β”œβ”€β”€ mail.js
β”‚   β”‚   └── pick.js
β”‚   β”‚
β”‚   β”œβ”€β”€ middlewares/              # Express middlewares
β”‚   β”‚   β”œβ”€β”€ auth.js
β”‚   β”‚   └── schemaValidation.js
β”‚   β”‚
β”‚   β”œβ”€β”€ models/                   # MongoDB models
β”‚   β”‚   └── user.model.js
β”‚   β”‚
β”‚   β”œβ”€β”€ routes/                   # API routes
β”‚   β”‚   β”œβ”€β”€ docs.routes.js
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── user.routes.js
β”‚   β”‚
β”‚   β”œβ”€β”€ utils/                    # Utility functions
β”‚   β”‚   β”œβ”€β”€ message.js
β”‚   β”‚   └── responses.js
β”‚   β”‚
β”‚   β”œβ”€β”€ validations/              # Request validations
β”‚   β”‚   β”œβ”€β”€ index.js
β”‚   β”‚   └── user.validation.js
β”‚   β”‚
β”‚   └── index.js                  # Application entry point
β”‚
β”œβ”€β”€ .env.example                  # Environment variables example file
β”œβ”€β”€ .gitignore                    # Git ignore file
β”œβ”€β”€ package.json                  # Project dependencies
└── README.md                     # Project documentation

πŸ† Best Practices βœ…

Code Style

  • Write meaningful commit messages
  • Document your code with JSDoc

Security

  • Always use environment variables for sensitive data
  • Implement proper input validation
  • Use parameterized queries to prevent SQL injection
  • Implement rate limiting and CORS

Performance

  • Use database indexing for frequently queried fields
  • Implement caching where appropriate
  • Optimize database queries
  • Use connection pooling for database connections

🀝 Contributing

Contributions, issues, and feature requests are welcome! Feel free to check the issues page.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

πŸ“ License

This project is licensed under the MIT License - see the LICENSE file for details.

Author πŸ‘¨β€πŸ’»

🌟 Support

If you find this project helpful, please consider giving it a ⭐️ on GitHub.

Acknowledgments