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-setup-express-backend

v4.0.3

Published

CLI to bootstrap a customizable Node.js API starter with optional MongoDB, Helmet, and folder structure. Express is always included.

Readme

🚀 Quick Start (Recommended)

Run the CLI instantly using npx instead of npm i:

npx create-setup-express-backend

🚀 create-setup-express-backend

A professional CLI tool to instantly scaffold a modern Express.js backend with optional MongoDB, Helmet security, recommended folder structure, auto environment setup, and optional demo APIs.

Built with ❤️ by Piyush Gupta to help developers ship backend projects faster, cleaner, and more efficiently.



📌 Table of Contents


✨ Overview

create-setup-express-backend is a CLI tool that generates a full Express backend structure in seconds.

It eliminates repetitive setup work like:

  • installing packages
  • setting up environment files
  • creating project folders
  • configuring MongoDB
  • adding security layers
  • building demo routes + controllers

Generate a backend in less than 10 seconds.


🔥 Features

🟢 Always Included

| Feature | Description | | -------------------- | ----------------------------------------- | | 🚀 Express.js | Always installed, pre-configured with ESM | | 📦 CORS + Dotenv | Included by default | | 🔄 Nodemon | Auto-installed as dev dependency | | 📜 Auto server.js | Clean and ready-to-run | | ⚙️ Auto dependencies | Runs npm install automatically |


🟡 Optional (User Selects)

| Option | Description | | --------------------- | --------------------------------- | | 🛢️ MongoDB (Mongoose) | Auto-connects + generates db.js | | 🛡 Helmet Security | Adds secure headers | | 📁 Folder Structure | Creates MVC folders | | 🧩 Demo API Files | Adds example route + controller |


⚙️ Installation

Use via npx (recommended)

npx create-setup-express-backend

Install globally

npm install -g create-setup-express-backend
create-setup-express-backend

🚀 Usage

Run:

npx create-setup-express-backend

The CLI then asks:

Project name:
Do you want MongoDB (Mongoose)?
Do you want Helmet?
Create folder structure?
Write demo files?
Default port:

After creation:

cd project-name
npm run dev

Your backend is live at:

http://localhost:5000

🎥 Demo (CLI GIF)

You can add a GIF of your CLI here:

CLI Demo


📁 Folder Structure

If folder structure is enabled:

my-api/
│
├── server.js
├── .env
│
├── config/
│   └── db.js
│
├── controllers/
│   └── homeController.js
│
├── routes/
│   └── index.js
│
└── models/

🧠 server.js Example

import dotenv from "dotenv";
dotenv.config();

import express from "express";
import cors from "cors";

const app = express();
app.use(cors());
app.use(express.json());

app.get("/", (req, res) => {
  res.json({
    message: "Server is running 🚀",
    createdBy: "Piyush Gupta (create-setup-express-backend)",
  });
});

const PORT = process.env.PORT || 5000;
app.listen(PORT, () => console.log(`🚀 Server running on port ${PORT}`));

🛢️ MongoDB Setup

When MongoDB is enabled, this file is generated:

config/db.js

import mongoose from "mongoose";

const connectDB = async () => {
  try {
    const conn = await mongoose.connect(process.env.MONGO_URI);
    console.log("🔥 MongoDB connected:", conn.connection.host);
  } catch (err) {
    console.error("❌ MongoDB Error:", err.message);
    process.exit(1);
  }
};

export default connectDB;

Automatically imported in server.js when selected.


🛡️ Helmet Security

If enabled:

import helmet from "helmet";
app.use(helmet());

Adds common security headers.


📝 Environment Variables

Generated .env:

PORT=5000
MONGO_URI=mongodb://127.0.0.1:27017/my_api
NODE_ENV=development

📘 Advanced Usage

Generate backend with MongoDB & structure:

npx create-setup-express-backend

Choose:

  • MongoDB → YES
  • Folder structure → YES
  • Demo files → YES

Run dev server:

npm run dev

Server auto-restarts on file change.

📄 License

MIT License — free for personal & commercial use.


👨‍💻 Author

Piyush Gupta
Full-Stack Developer | Backend Engineer

📧 Email: [email protected]
🔗 LinkedIn: linkedin.com/in/piyush-gupta-06b020213/ 💻 GitHub: github.com/hackhub817


⭐ Support

If you like this package:

  • ⭐ Star the GitHub repo
  • 📦 Use it in your projects
  • 🔗 Share it with other developers
  • 💬 Post about it on LinkedIn

Made with ❤️ by Piyush Gupta