** Jumpstart your next project with a modern, secure, and production-ready REST API boilerplate.**
Built for speed, learning, and real-world use.
- 🚀 No more boilerplate headache: Authentication, CRUD, modular structure, all ready-to-go.
- 🧑💻 Perfect for hackathons, startups, tutorials, and open source.
- 🌎 Deploy to the cloud, demo for your team, or learn best practices by example.
Give your next Node.js API a professional foundation—with one git clone.
A modern, beginner-friendly REST API boilerplate for Node.js. Features user authentication with JWT, modular project structure, clean code, and MongoDB integration. Ideal for building scalable APIs, learning backend best practices, or starting a new project!
- User authentication (register/login) with JWT
- Modular structure: controllers, models, routes, middlewares
- Sample protected resource CRUD (Posts)
- Centralized error handling
- MongoDB with Mongoose (ready for cloud or local)
- ESLint + Prettier for code quality
- .env.example included for easy setup
- Node.js, Express
- MongoDB (Mongoose)
- JWT (jsonwebtoken)
- ESLint & Prettier
- dotenv
- Clone the repo:
git clone https://github.com/Yasir-Rafique/rest-api-starter.git
cd rest-api-starter
- Install dependencies:
npm install
- Configure environment variables:
- Copy .env.example to .env
- Fill in your values (see comments in file)
- Start MongoDB:
- Use MongoDB Atlas (recommended!) or local MongoDB
- Run the server:
npm run dev
- Your server runs on http://localhost:5000 by default
Auth
- POST /api/auth/register — Register a new user
- POST /api/auth/login — Log in and get JWT token
- GET /api/auth/me — Get current user (protected)
Posts (all require JWT in Authorization: Bearer )
- POST /api/posts — Create post
- GET /api/posts — List all your posts
- GET /api/posts/:id — Get a specific post
- PUT /api/posts/:id — Update your post
- DELETE /api/posts/:id — Delete your post
Register
POST /api/auth/register
{
"name": "Your Name",
"email": "[email protected]",
"password": "yourpassword"
}
Login
POST /api/auth/login
{
"email": "[email protected]",
"password": "yourpassword"
}
Copy the token from login and use it in protected routes:
Authorization: Bearer <token>
📝 Contributing
- Fork the repo
- Create a new branch (git checkout -b feature/your-feature)
- Commit your changes (git commit -am 'Add something')
- Push to the branch (git push origin feature/your-feature)
- Open a Pull Request
⭐ Like this project? Give it a star! Sharing and feedback are appreciated.
🪪 License MIT — see LICENSE for details.