Skip to content

Production-ready REST API Starter built with Node.js, Express, JWT Auth & MongoDB (Mongoose). Secure, modular, and open source. Kickstart your backend project with best practices built-in!

License

Notifications You must be signed in to change notification settings

Yasir-Rafique/rest-api-starter

Repository files navigation

Node.js Express MongoDB PRs Welcome MIT License

REST API Starter - Minimal Banner

🚀 REST API Starter

** 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.


🧑‍💻 About

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!


✨ Features

  • 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

🛠️ Tech Stack

  • Node.js, Express
  • MongoDB (Mongoose)
  • JWT (jsonwebtoken)
  • ESLint & Prettier
  • dotenv

🚀 Getting Started

  1. Clone the repo:
git clone https://github.com/Yasir-Rafique/rest-api-starter.git
cd rest-api-starter
  1. Install dependencies:
npm install
  1. Configure environment variables:
  • Copy .env.example to .env
  • Fill in your values (see comments in file)
  1. Start MongoDB:
  1. Run the server:
npm run dev

🛡️ API Endpoints

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

📬 Example Requests

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.


About

Production-ready REST API Starter built with Node.js, Express, JWT Auth & MongoDB (Mongoose). Secure, modular, and open source. Kickstart your backend project with best practices built-in!

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published