A full-stack blog application built with Node.js, Express, and MongoDB. This application provides a robust API for managing blog posts, users, categories, and authentication.
- User authentication and authorization
- Blog post management (CRUD operations)
- Category management
- User profile management
- Post likes functionality
- Image upload support using Cloudinary
- RESTful API architecture
- Backend: Node.js, Express.js
- Database: MongoDB with Mongoose
- Authentication: JWT (JSON Web Tokens)
- File Upload: Cloudinary, Multer
- Other Tools: bcrypt for password hashing, cors for cross-origin requests
- Node.js (v14 or higher)
- MongoDB
- Cloudinary account (for image uploads)
- Clone the repository:
git clone https://github.com/SwapnilMk/techtea-server.git
cd techtea-server- Install dependencies:
npm install- Create a
.envfile in the root directory with the following variables:
PORT=8080
MONGODB_URI=your_mongodb_connection_string
JWT_SECRET=your_jwt_secret
CLOUDINARY_CLOUD_NAME=your_cloudinary_cloud_name
CLOUDINARY_API_KEY=your_cloudinary_api_key
CLOUDINARY_API_SECRET=your_cloudinary_api_secret
- Start the development server:
npm run devPOST /api/auth/register- Register a new userPOST /api/auth/login- Login user
GET /api/users- Get all usersGET /api/users/:id- Get user by IDPUT /api/users/:id- Update userDELETE /api/users/:id- Delete user
GET /api/posts- Get all postsGET /api/posts/:id- Get post by IDPOST /api/posts- Create new postPUT /api/posts/:id- Update postDELETE /api/posts/:id- Delete post
GET /api/categories- Get all categoriesPOST /api/categories- Create new categoryPUT /api/categories/:id- Update categoryDELETE /api/categories/:id- Delete category
techtea-server/
├── config/ # Configuration files
├── models/ # Database models
├── routes/ # API routes
├── utils/ # Utility functions
├── index.js # Main application file
└── package.json # Project dependencies
npm run dev- Start development server with nodemonnpm start- Start production server
The application includes global error handling middleware that catches and processes errors appropriately, returning meaningful error messages to the client.
- Password hashing using bcrypt
- JWT-based authentication
- CORS enabled
- Request size limits
- Environment variable configuration
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request