This is the backend for BlogApp, a blogging platform that allows users to create, read, update, and delete blog posts. It includes user authentication, media uploads, and email verification.
- Backend Framework: Express.js
- Database: MongoDB (with Mongoose ODM)
- Authentication: JWT (JSON Web Token)
- File Uploads: Cloudinary & Multer
- Security: bcrypt for password hashing
- Email Service: Nodemailer
- Other Dependencies: CORS, dotenv, cookie-parser
For full API documentation and testing, visit the following Postman collection:
The backend is deployed on Render.
git clone https://github.com/aakritrajput/BlogAppBackend.git
cd BlogAppBackendnpm installCreate a .env file in the root directory and add the following:
PORT=
MONGODB_URI=
CORS_ORIGIN=
ACCESS_TOKEN_SECRET=
ACCESS_TOKEN_EXPIRY=
REFRESH_TOKEN_SECRET=
REFRESH_TOKEN_EXPIRY=
CLOUDINARY_CLOUD_NAME=
CLOUDINARY_API_KEY=
CLOUDINARY_API_SECRET=
VERIFICATION_TOKEN_SECRET=
VERIFICATION_TOKEN_EXPIRY=
PROJECT_OWNER_EMAIL=
PROJECT_OWNER_PASSWORD=
NODE_ENV=npm start✅ User authentication (JWT-based)
✅ CRUD operations for blog posts
✅ Image upload using Cloudinary
✅ Email verification via Nodemailer
✅ Pagination using mongoose-aggregate-paginate-v2
BlogAppBackend/
│-- public/ # Stores images locally during upload
│-- src/
│ ├── controllers/ # Business logic for routes
│ ├── routes/ # API route handlers
│ ├── middlewares/ # Middleware functions (auth, error handling)
│ ├── models/ # Mongoose models (User, Post, etc.)
│ ├── utils/ # Helper utilities (email, file upload, etc.)
│ ├── db/ # Database connection setup
│ ├── index.js # Entry point
│-- .env.example # Environment variable sample
│-- package.json # Dependencies and scripts