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-bodhi-node-boilerplate

v1.3.0

Published

Create a Node.js project with basic folder structure and server setup

Readme

Create Bodhi Node Boilerplate

A powerful Node.js boilerplate generator with JWT authentication, MongoDB integration, and a beautiful ASCII art banner.

Installation & Usage

You can create a new project in three ways:

1. Using npx (Recommended)

# Create a new project
npx create-bodhi-node-boilerplate my-project

# Navigate to project
cd my-project

# Install dependencies
npm install

# Start development server
npm run dev

2. Using npm globally

# Install package globally
npm install -g create-bodhi-node-boilerplate

# Create a new project
create-bodhi-node-boilerplate my-project

# Navigate to project
cd my-project

# Install dependencies
npm install

# Start development server
npm run dev

3. Using npm init

# Create a new project
npm init bodhi-node-boilerplate my-project

# Navigate to project
cd my-project

# Install dependencies
npm install

# Start development server
npm run dev

Features

  • 🚀 Express.js server setup
  • 🔐 JWT Authentication (access & refresh tokens)
  • 📦 MongoDB integration
  • 🎨 Beautiful ASCII art banner
  • 🔄 Auto-reload with nodemon
  • ⚡ Environment variable configuration
  • 🛡️ CORS enabled
  • 🎯 Clean project structure

A production-ready Node.js REST API boilerplate with authentication, security, and best practices built-in.

A Note from the Creator 💭

Just as frontend developers have create-react-app to jumpstart their React projects, backend developers deserve a robust solution for Node.js applications. That's why I created bodhi-node-boilerplate - to provide backend developers with a production-ready, feature-rich foundation for their REST APIs.

No more spending hours on boilerplate code or worrying about security configurations. With Bodhi Node App, you get a professionally structured Node.js application with all the essential features you need to build secure, scalable APIs.

Created with ❤️ by Bodheesh

Support 🌟

If you find this project helpful, please give it a star ⭐ on GitHub! It helps more developers discover this tool.

Why Bodhi Node App? 🤔

While frontend developers have had tools like create-react-app for years, backend developers have been left to configure their Node.js applications from scratch. Bodhi Node boilerplate changes that by providing:

  • 🔒 Production-ready JWT authentication
  • 🛡️ Security best practices out of the box
  • 📝 API documentation with examples
  • 🔄 Refresh token rotation
  • 🎯 Clean and scalable project structure

Project Structure

my-project/
├── src/
│   ├── config/
│   │   └── config.js         # Configuration management
│   ├── controllers/
│   │   ├── authController.js # Authentication logic
│   │   └── userController.js # User management
│   ├── middleware/
│   │   └── auth.js          # JWT verification
│   ├── models/
│   │   └── userModel.js     # User schema and methods
│   ├── routes/
│   │   ├── authRoutes.js    # Auth endpoints
│   │   └── userRoutes.js    # User endpoints
│   ├── utils/
│   │   └── ascii-art.js     # ASCII banner
│   └── app.js               # Express app setup
├── .env                     # Environment variables
└── package.json            # Project dependencies

API Endpoints

Authentication

  • POST /api/v1/auth/register - Register a new user
  • POST /api/v1/auth/login - Login user
  • GET /api/v1/auth/me - Get current user profile (protected)
  • POST /api/v1/auth/refresh-token - Refresh access token
  • POST /api/v1/auth/logout - Logout user (protected)

User Management

  • PUT /api/v1/users/profile - Update user's profile (protected)
  • DELETE /api/v1/users/account - Delete user's account (protected)

API Testing

Using cURL

Authentication APIs

  1. Register a new user
curl -X POST http://localhost:7000/api/v1/auth/register \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe",
    "email": "[email protected]",
    "password": "password123"
  }'
  1. Login
curl -X POST http://localhost:7000/api/v1/auth/login \
  -H "Content-Type: application/json" \
  -d '{
    "email": "[email protected]",
    "password": "password123"
  }'
  1. Get Current User Profile (Protected)
curl -X GET http://localhost:7000/api/v1/auth/me \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
  1. Refresh Token
curl -X POST http://localhost:7000/api/v1/auth/refresh-token \
  -H "Content-Type: application/json" \
  -d '{
    "refreshToken": "YOUR_REFRESH_TOKEN"
  }'
  1. Logout (Protected)
curl -X POST http://localhost:7000/api/v1/auth/logout \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

User Management APIs

  1. Update User Profile (Protected)
curl -X PUT http://localhost:7000/api/v1/users/profile \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \
  -H "Content-Type: application/json" \
  -d '{
    "username": "johndoe_updated",
    "email": "[email protected]"
  }'
  1. Delete Account (Protected)
curl -X DELETE http://localhost:7000/api/v1/users/account \
  -H "Authorization: Bearer YOUR_ACCESS_TOKEN"

Using Postman

  1. Download the Postman collection:

  2. Import the collection in Postman:

    • Open Postman
    • Click "Import"
    • Choose the downloaded collection file
  3. Set up environment variables in Postman:

    • Create a new environment (e.g., "Bodhi Local")
    • Add these variables:
      • baseUrl: http://localhost:7000
      • accessToken: (will be automatically set after login)
      • refreshToken: (will be automatically set after login)
  4. Test Flow:

    • Register a new user
    • Login to get tokens
    • Use other endpoints with the obtained token

Example API Responses

  1. Successful Registration
{
  "success": true,
  "message": "User registered successfully",
  "data": {
    "user": {
      "id": "user_id",
      "username": "johndoe",
      "email": "[email protected]"
    }
  }
}
  1. Successful Login
{
  "success": true,
  "message": "Login successful",
  "data": {
    "user": {
      "id": "user_id",
      "username": "johndoe",
      "email": "[email protected]"
    },
    "tokens": {
      "accessToken": "eyJhbG...",
      "refreshToken": "eyJhbG..."
    }
  }
}

Error Responses

{
  "success": false,
  "message": "Error message here",
  "error": {
    "code": "ERROR_CODE",
    "details": "Detailed error message"
  }
}

Common error codes:

  • AUTH_INVALID_CREDENTIALS: Invalid email or password
  • AUTH_TOKEN_EXPIRED: JWT token has expired
  • AUTH_TOKEN_INVALID: Invalid JWT token
  • USER_NOT_FOUND: User not found
  • VALIDATION_ERROR: Invalid input data

Environment Variables

The following environment variables are used:

PORT=7000                    # Server port
NODE_ENV=development        # Environment mode
MONGODB_URI=mongodb://127.0.0.1:27017/my-project  # MongoDB connection URL
JWT_SECRET=your-secret      # JWT signing key
JWT_REFRESH_SECRET=your-refresh-secret  # Refresh token key
JWT_ACCESS_EXPIRE=15m      # Access token expiry
JWT_REFRESH_EXPIRE=7d      # Refresh token expiry

Prerequisites

  • Node.js >= 14
  • MongoDB >= 4.0

Scripts

  • npm start - Start production server
  • npm run dev - Start development server with auto-reload

MongoDB Setup

  1. Install MongoDB Community Server from mongodb.com
  2. Start MongoDB service
  3. The app will automatically create the database on first run

Common Issues

  1. MongoDB Connection Error

    • Ensure MongoDB is running
    • Check if the MongoDB URI in .env is correct
    • Try using '127.0.0.1' instead of 'localhost'
  2. Port Already in Use

    • Change the PORT in .env file
    • Default port is 7000

License

MIT

Contributing

Feel free to open issues and pull requests!