A full-featured RESTful API for managing personal contacts with user authentication, photo uploads, password reset functionality, and OpenAPI documentation.
➡️ [https://contacts-api-b5n1.onrender.com/api-docs/]
- ✅ User registration, login and protected routes
- ✅ JWT-based authentication
- ✅ Full CRUD for contacts
- ✅ File uploads to Cloudinary
- ✅ Pagination, sorting & filtering
- ✅ Password reset via email
- ✅ Swagger documentation at
/api-docs - ✅ MongoDB with Mongoose
- ✅ Input validation via Joi
- ✅ Error handling middleware
- ✅ Modern project structure with MVC
- ✅ Environment variable support via
.env
- Node.js, Express
- MongoDB + Mongoose
- Cloudinary for image storage
- Joi for validation
- bcrypt for password hashing
- JWT for auth
- Nodemailer for email
- Swagger + Redoc for docs
See .env.example for required environment variables:
PORT=
DB_URI=
JWT_SECRET=
JWT_EXPIRES_IN=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
EMAIL_USER=
EMAIL_PASS=
CLIENT_URL= # used in reset password emailnpm run dev
npm start
npm run docs
🧰 API Endpoints
🔐 Auth POST /auth/register POST /auth/login POST /auth/logout POST /auth/refresh POST /auth/send-reset-email POST /auth/reset-pwd
👤 Contacts GET /contacts GET /contacts/:contactId POST /contacts (supports file upload) PATCH /contacts/:contactId DELETE /contacts/:contactId
Supports:
?page=1&perPage=10 ?sortBy=name&sortOrder=asc ?isFavourite=true&contactType=personal
📸 Photo Upload
You can upload a contact photo in POST /contacts Images are stored on Cloudinary Response includes photo URL
📑 API Documentation
Visit: [https://contacts-api-b5n1.onrender.com/api-docs/] Swagger UI powered by swagger-ui-express
🧪 Testing (Postman etc.)
All endpoints tested and documented. Feel free to import the Swagger JSON or use /api-docs for testing.