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

create-be-boilerplate

v2.0.0

Published

CLI to create a Node.js + Express backend boilerplate with JWT, middlewares, and utilities

Downloads

138

Readme

🚀 Backend Template (JavaScript + Express + Mongoose)

A clean and modern backend starter using JavaScript, Express, and Mongoose, designed to help you build scalable Node.js APIs fast.


🚀 Usage & ⚙️ Setup

use to initialed project

npx create-be-boilerplate my-app

1️⃣ Install dependencies

cd my-app

npm install

2️⃣ Update .env and configs file

1. Create your environment file

  • Copy the example file and rename it:
cp .env.example .env

2. Update your app.js configuration

  • If your app.js currently loads:
dotenv.config({ path: ".env" });
  • Replace it with one of these options:

Option A — Load the .env file explicitly

dotenv.config({ path: ".env" });

Option B — Let dotenv load .env automatically (recommended)

dotenv.config();

Your application will now read all environment variables from the newly created .env file.

3️⃣ Run in development

npm run dev

🧠 Example Endpoints

| Method | Endpoint | Description | |---------|-------------|-------------| | GET | / | Health check | | POST | api/auth/register | To create new user | | GET | api/users | Get all users|


🧩 Features

  • ⚙️ JavaScript-based structure
  • 🧱 Express with modular architecture
  • 📦 Mongoose ORM for MongoDB
  • 🔐 Ready for authentication with refresh token and access token feature (JWT + bcrypt)
  • 🧰 Built-in utilities for response formatting and error handling
  • 🌱 Pre-configured environment setup

📁 Folder Structure

├── 📁 template (my-app folder)
│   ├── 📁 public
│   │   └── 📁 images
│   │       └── 🖼️ test.png
│   ├── 📁 src
│   │   ├── 📁 config                   # DB and environment setup (db.js, api config, dotenv)
│   │   │   ├── 📄 api.js               # API configuration / constants
│   │   │   └── 📄 db.js                # Database connection logic (Mongoose)
│   │   ├── 📁 constants                # Static constants, enums, fixed values
│   │   │   └── 📄 user.js              # User-related constant values
│   │   ├── 📁 controllers              # Business logic controllers
│   │   │   ├── 📄 auth.controller.js   # Auth logic (register, login, refresh, logout)
│   │   │   └── 📄 user.controller.js   # User CRUD and profile handlers
│   │   ├── 📁 middlewares              # Custom middleware functions
│   │   │   ├── 📄 auth.js              # Auth verification middleware
│   │   │   ├── 📄 authorizeRoles.js    # RBAC: role-based access control
│   │   │   ├── 📄 errorHandler.js      # Global error handler middleware
│   │   │   ├── 📄 fileRestoreUpload.js # Restore uploaded file if failure occurs
│   │   │   ├── 📄 imageUpload.js       # Image upload helper (multer / sharp)
│   │   │   └── 📄 validate.js          # Request validation handler
│   │   ├── 📁 models                   # Mongoose schemas and models
│   │   │   └── 📄 user.model.js        # User schema definition
│   │   ├── 📁 routes                   # API route definitions
│   │   │   ├── 📄 auth.routes.js       # Auth API routes
│   │   │   ├── 📄 health.routes.js     # Server health check route
│   │   │   └── 📄 index.js             # Route aggregator
│   │   ├── 📁 services                 # Database access & domain logic
│   │   │   └── 📄 user.service.js      # User model service (DB queries)
│   │   ├── 📁 utils                    # Helper utilities & shared logic
│   │   │   ├── 📄 appError.js          # Custom error constructor
│   │   │   ├── 📄 cookies.js           # Cookie utilities
│   │   │   ├── 📄 cryptoHelper.js      # Encryption / random utilities
│   │   │   ├── 📄 hash.js              # Password hashing / comparing
│   │   │   ├── 📄 helper.js            # General-purpose helper functions
│   │   │   ├── 📄 httpStatus.js        # Status code + messages map
│   │   │   ├── 📄 jwt.js               # JWT generation + verification utils
│   │   │   ├── 📄 mongoErrorFormatter.js # MongoDB error beautifier
│   │   │   ├── 📄 response.js          # Standard API response builder
│   │   │   └── 📄 sendEmail.js         # Email sender wrapper (nodemailer)
│   │   ├── 📁 validations              # Payload / schema validators
│   │   │   ├── 📄 common.validation.js # Common reusable validation schemas
│   │   │   └── 📄 user.validation.js   # User input validations
│   │   ├── 📄 app.js                   # Express app setup (middleware, routes)
│   │   └── 📄 server.js                # App entry point (starts the server)
│   ├── ⚙️ .env.example                 # Example environment template
│   ├── ⚙️ .gitignore                  # Files ignored by Git
│   ├── ⚙️ .prettierrc                 # Prettier formatting rules
│   ├── 📝 README.md                   # Documentation for the boilerplate
│   ├── 📄 eslint.config.js            # ESLint configuration
│   ├── ⚙️ package.json                # Project dependencies & scripts
│   └── ⚙️ vercel.json                 # Vercel deployment config

🧰 Tech Stack

  • Node.js + Express

  • JavaScript

  • MongoDB + Mongoose

  • Helmet, CORS, Morgan

  • Dotenv for config management