nodejs-rest-api-boilerplate
Node.js REST API Boilerplate
A production-ready Node.js + Express REST API starter with JWT authentication, rate limiting, and CRUD endpoints.
Features
- JWT Authentication (register + login endpoints)
- Express Rate Limiting (100 req/15 min per IP)
- CORS configured for cross-origin frontend apps
- Modular route structure under
/api/v1/ - Full CRUD for posts resource
- Health check endpoint
- Clean JSON error responses
API Endpoints
| Method | Endpoint | Description |
|---|---|---|
| POST | /api/v1/auth/register | Register new user |
| POST | /api/v1/auth/login | Login and get JWT |
| GET | /api/v1/users/me | Get current user profile |
| GET | /api/v1/posts | List all posts |
| POST | /api/v1/posts | Create a new post |
| DELETE | /api/v1/posts/:id | Delete a post |
| GET | /health | Server health check |
Setup
npm install
npm start
# API runs at http://localhost:3000
Tech Stack
- Node.js 20+
- Express.js 4.18
- express-rate-limit
- CORS middleware
Use Cases
- Backend API for React/Vue/Next.js apps
- Microservice starter template
- REST API learning project
- SaaS backend boilerplate
Link copied!