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

node-backend-generator

v1.2.4

Published

πŸš€ CLI tool to generate professional Node.js backend templates with best practices, multiple databases, authentication, and production-ready features

Readme

Node Backend Generator πŸš€

npm version npm downloads License: MIT Node.js Version

A powerful CLI tool to generate professional, production-ready Node.js backend templates in seconds.
Choose your database, features, and get a complete backend with industry best practices.


✨ Features

  • πŸš€ Multiple Databases – MongoDB (Mongoose), MySQL/PostgreSQL (Sequelize), Prisma, or Database-less
  • πŸ” Authentication – JWT with refresh tokens, bcrypt password hashing
  • πŸ“ File Upload – Multer with validation & multiple file support
  • πŸ“§ Email Service – Nodemailer with ready templates (welcome, password reset, notifications)
  • πŸ“š API Documentation – Auto-generated Swagger/OpenAPI docs
  • 🐳 Docker Support – Dockerfile + docker-compose with database setup
  • πŸ›‘οΈ Security – Helmet, CORS, rate limiting, input validation
  • ⚑ Modern JS – ES Modules & CommonJS support
  • 🎯 Production Ready – Error handling, logging, environment config

πŸš€ Quick Start

Using npx (Recommended β€” No Installation Needed)

npx node-backend-generator@latest

Global Installation

npm install -g node-backend-generator

create-node-backend

Local Installation

npm install node-backend-generator
npx create-node-backend

🧭 Usage

1️⃣ Run the Generator

npx node-backend-generator@latest

2️⃣ Follow the Interactive Prompts

You’ll be guided through setting up your project:

Enter your project name: my-awesome-api

Example Interactive Setup:

? Enter your project name: my-awesome-api
? Choose module system:
❯ ES Modules (MJS)
  CommonJS (CJS)

? Choose database ORM:
❯ Mongoose (MongoDB)
  Sequelize (MySQL/PostgreSQL)
  Prisma (Multi-database)
  None (API only)

? Select additional features:
β—‰ Authentication (JWT)
β—‰ API Documentation (Swagger)
β—― File Upload (Multer)
β—― Email Service (Nodemailer)
β—― Docker Support
β—‰ Rate Limiting
β—‰ Input Validation

3️⃣ Generated Project Structure

my-awesome-api/
β”œβ”€β”€ server.js
β”œβ”€β”€ package.json
β”œβ”€β”€ .env
β”œβ”€β”€ .env.example
β”œβ”€β”€ .gitignore
β”œβ”€β”€ Dockerfile
β”œβ”€β”€ docker-compose.yml
β”œβ”€β”€ src/
β”‚   β”œβ”€β”€ config/
β”‚   β”œβ”€β”€ controllers/
β”‚   β”œβ”€β”€ models/
β”‚   β”œβ”€β”€ routes/
β”‚   β”œβ”€β”€ middlewares/
β”‚   β”œβ”€β”€ services/
β”‚   └── utils/
β”œβ”€β”€ uploads/
└── tests/

4️⃣ Get Started with Your New Project

cd my-awesome-api
npm install
cp .env.example .env

# Prisma only
npx prisma generate
npx prisma db push

# Start development server
npm run dev

# Or production
npm start

🎯 Available Scripts

npm start          # Start production server
npm run dev        # Start development server with nodemon
npm test           # Run tests
npm run lint       # Lint code
npm run lint:fix   # Auto-fix lint issues

πŸ“š API Endpoints

πŸ” Authentication (if enabled)

POST /api/auth/register      # Register user
POST /api/auth/login         # Login user
GET  /api/auth/profile       # Get logged-in profile

πŸ‘€ User Routes

GET /api/users
GET /api/users/:id

πŸ“ File Upload (if enabled)

POST /api/upload/single
POST /api/upload/multiple

πŸ“§ Email Service (if enabled)

POST /api/email/test
POST /api/email/password-reset
POST /api/email/welcome

🧰 Utilities

GET /health
GET /api-docs

πŸ”§ Configuration

Environment Variables (.env)

# Server
NODE_ENV=development
PORT=3000

# Database
MONGODB_URI=mongodb://localhost:27017/your-db
# OR
DATABASE_URL="mysql://root:password@localhost:3306/your-db"

# JWT
JWT_SECRET=your_super_secret_key
JWT_EXPIRES_IN=7d

# Email
SMTP_HOST=your-smtp-host
SMTP_PORT=587
[email protected]
SMTP_PASS=your-password

πŸ—„οΈ Database Setup

MongoDB (Mongoose)

  1. Install MongoDB or use Atlas.
  2. Update MONGODB_URI in .env.
  3. Done! No schema migration needed.

MySQL / PostgreSQL (Sequelize)

  1. Install the respective DB.
  2. Create your database.
  3. Update .env credentials.

Prisma

npx prisma generate
npx prisma db push

🐳 Docker Support

If you selected Docker:

docker-compose up -d        # Start DB & app
docker build -t my-backend .
docker run -p 3000:3000 my-backend

πŸ” Authentication Usage

Register a User

POST /api/auth/register
{
  "name": "John Doe",
  "email": "[email protected]",
  "password": "securepassword"
}

Login

POST /api/auth/login
{
  "email": "[email protected]",
  "password": "securepassword"
}

Protected Routes

Include JWT token in headers:

Authorization: Bearer <your_jwt_token_here>

πŸ“ File Upload Example

const formData = new FormData();
formData.append('file', fileInput.files[0]);

fetch('/api/upload/single', {
  method: 'POST',
  headers: { Authorization: 'Bearer your-token' },
  body: formData,
});

πŸ“§ Email Service Example

Send Test Email

POST /api/email/test
{
  "email": "[email protected]"
}

Request Password Reset

POST /api/email/password-reset
{
  "email": "[email protected]"
}

πŸ› οΈ Customization

Add a New Route

  • Create a controller in src/controllers/
  • Add a route in src/routes/
  • Import it in server.js

Add a New Model

  • Add a model in src/models/
  • Use it in your controller logic

Add Middleware

  • Create in src/middlewares/
  • Register globally or per-route in server.js

🀝 Support

  • πŸ“˜ Docs: Visit /api-docs after starting your server
  • 🐞 Issues: GitHub Issues
  • πŸ’¬ FAQ: See in docs or discussions

πŸ“„ License

MIT License β€” see LICENSE for details.


πŸ™ Contributing

We welcome contributions!
Please read our Contributing Guide before submitting PRs.


✨ Happy Coding! ✨
Generated with ❀️ by Trina Dasgupta