Gathering detailed insights and metrics for create-bodhi-node-boilerplate
Gathering detailed insights and metrics for create-bodhi-node-boilerplate
Gathering detailed insights and metrics for create-bodhi-node-boilerplate
Gathering detailed insights and metrics for create-bodhi-node-boilerplate
npm install create-bodhi-node-boilerplate
Typescript
Module System
Node Version
NPM Version
Cumulative downloads
Total Downloads
Last Day
0%
NaN
Compared to previous day
Last Week
0%
NaN
Compared to previous week
Last Month
0%
NaN
Compared to previous month
Last Year
0%
NaN
Compared to previous year
A powerful Node.js boilerplate generator with JWT authentication, MongoDB integration, and a beautiful ASCII art banner.
You can create a new project in three ways:
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
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
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
A production-ready Node.js REST API boilerplate with authentication, security, and best practices built-in.
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
If you find this project helpful, please give it a star ⭐ on GitHub! It helps more developers discover this tool.
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:
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
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)PUT /api/v1/users/profile
- Update user's profile (protected)DELETE /api/v1/users/account
- Delete user's account (protected)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 }'
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 }'
1curl -X GET http://localhost:7000/api/v1/auth/me \ 2 -H "Authorization: Bearer YOUR_ACCESS_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 }'
1curl -X POST http://localhost:7000/api/v1/auth/logout \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
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 }'
1curl -X DELETE http://localhost:7000/api/v1/users/account \ 2 -H "Authorization: Bearer YOUR_ACCESS_TOKEN"
Download the Postman collection:
Import the collection in Postman:
Set up environment variables in Postman:
baseUrl
: http://localhost:7000accessToken
: (will be automatically set after login)refreshToken
: (will be automatically set after login)Test Flow:
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}
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}
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 dataThe 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
npm start
- Start production servernpm run dev
- Start development server with auto-reloadMongoDB Connection Error
Port Already in Use
MIT
Feel free to open issues and pull requests!
No vulnerabilities found.
No security vulnerabilities found.