Installations
npm install create-bodhi-node-boilerplate
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
18.17.1
NPM Version
10.9.0
Releases
Unable to fetch releases
validate.email š
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Download Statistics
Total Downloads
645
Last Day
1
Last Week
9
Last Month
645
Last Year
645
Package Meta Information
Latest Version
1.3.0
Package Id
create-bodhi-node-boilerplate@1.3.0
Unpacked Size
37.04 kB
Size
9.08 kB
File Count
17
NPM Version
10.9.0
Node Version
18.17.1
Published on
Feb 05, 2025
Total Downloads
Cumulative downloads
Total Downloads
645
Last Day
-75%
1
Compared to previous day
Last Week
-10%
9
Compared to previous week
Last Month
0%
645
Compared to previous month
Last Year
0%
645
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
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)
1# Create a new project 2npx create-bodhi-node-boilerplate my-project 3 4# Navigate to project 5cd my-project 6 7# Install dependencies 8npm install 9 10# Start development server 11npm run dev
2. Using npm globally
1# Install package globally 2npm install -g create-bodhi-node-boilerplate 3 4# Create a new project 5create-bodhi-node-boilerplate my-project 6 7# Navigate to project 8cd my-project 9 10# Install dependencies 11npm install 12 13# Start development server 14npm run dev
3. Using npm init
1# Create a new project 2npm init bodhi-node-boilerplate my-project 3 4# Navigate to project 5cd my-project 6 7# Install dependencies 8npm install 9 10# Start development server 11npm 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 userPOST /api/v1/auth/login
- Login userGET /api/v1/auth/me
- Get current user profile (protected)POST /api/v1/auth/refresh-token
- Refresh access tokenPOST /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
- Register a new user
1curl -X POST http://localhost:7000/api/v1/auth/register \ 2 -H "Content-Type: application/json" \ 3 -d '{ 4 "username": "johndoe", 5 "email": "john@example.com", 6 "password": "password123" 7 }'
- Login
1curl -X POST http://localhost:7000/api/v1/auth/login \ 2 -H "Content-Type: application/json" \ 3 -d '{ 4 "email": "john@example.com", 5 "password": "password123" 6 }'
- Get Current User Profile (Protected)
1curl -X GET http://localhost:7000/api/v1/auth/me \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
- Refresh Token
1curl -X POST http://localhost:7000/api/v1/auth/refresh-token \ 2 -H "Content-Type: application/json" \ 3 -d '{ 4 "refreshToken": "YOUR_REFRESH_TOKEN" 5 }'
- Logout (Protected)
1curl -X POST http://localhost:7000/api/v1/auth/logout \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
User Management APIs
- Update User Profile (Protected)
1curl -X PUT http://localhost:7000/api/v1/users/profile \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN" \ 3 -H "Content-Type: application/json" \ 4 -d '{ 5 "username": "johndoe_updated", 6 "email": "john.updated@example.com" 7 }'
- Delete Account (Protected)
1curl -X DELETE http://localhost:7000/api/v1/users/account \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Using Postman
-
Download the Postman collection:
-
Import the collection in Postman:
- Open Postman
- Click "Import"
- Choose the downloaded collection file
-
Set up environment variables in Postman:
- Create a new environment (e.g., "Bodhi Local")
- Add these variables:
baseUrl
: http://localhost:7000accessToken
: (will be automatically set after login)refreshToken
: (will be automatically set after login)
-
Test Flow:
- Register a new user
- Login to get tokens
- Use other endpoints with the obtained token
Example API Responses
- Successful Registration
1{ 2 "success": true, 3 "message": "User registered successfully", 4 "data": { 5 "user": { 6 "id": "user_id", 7 "username": "johndoe", 8 "email": "john@example.com" 9 } 10 } 11}
- Successful Login
1{ 2 "success": true, 3 "message": "Login successful", 4 "data": { 5 "user": { 6 "id": "user_id", 7 "username": "johndoe", 8 "email": "john@example.com" 9 }, 10 "tokens": { 11 "accessToken": "eyJhbG...", 12 "refreshToken": "eyJhbG..." 13 } 14 } 15}
Error Responses
1{ 2 "success": false, 3 "message": "Error message here", 4 "error": { 5 "code": "ERROR_CODE", 6 "details": "Detailed error message" 7 } 8}
Common error codes:
AUTH_INVALID_CREDENTIALS
: Invalid email or passwordAUTH_TOKEN_EXPIRED
: JWT token has expiredAUTH_TOKEN_INVALID
: Invalid JWT tokenUSER_NOT_FOUND
: User not foundVALIDATION_ERROR
: Invalid input data
Environment Variables
The following environment variables are used:
1PORT=7000 # Server port 2NODE_ENV=development # Environment mode 3MONGODB_URI=mongodb://127.0.0.1:27017/my-project # MongoDB connection URL 4JWT_SECRET=your-secret # JWT signing key 5JWT_REFRESH_SECRET=your-refresh-secret # Refresh token key 6JWT_ACCESS_EXPIRE=15m # Access token expiry 7JWT_REFRESH_EXPIRE=7d # Refresh token expiry
Prerequisites
- Node.js >= 14
- MongoDB >= 4.0
Scripts
npm start
- Start production servernpm run dev
- Start development server with auto-reload
MongoDB Setup
- Install MongoDB Community Server from mongodb.com
- Start MongoDB service
- The app will automatically create the database on first run
Common Issues
-
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'
-
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!

No vulnerabilities found.

No security vulnerabilities found.