A RESTful API backend for a blog application built with Node.js, Express, and MongoDB.
- User authentication (JWT)
- OAuth 2.0 with GitHub
- Blog post CRUD operations
- Token refresh mechanism
- Swagger API documentation
- Protected routes with middleware
- Node.js
- Express.js
- MongoDB
- JWT (JSON Web Tokens)
- Swagger/OpenAPI
- Bcrypt for password hashing
Access the API documentation at: http://localhost:4500/api-docs
- Node.js (v14 or higher)
- MongoDB
- Git
- Clone the repository
git clone <repository-url>
cd Blog_Client_Backend
- Install dependencies
npm install
- Create a
.env
file in the root directory:
PORT=4500
URL="mongodb://127.0.0.1:27017/blogAppdb"
jwtSecretKey="your-secret-key"
REF_SECRET="your-refresh-secret"
CLIENT_ID="your-github-client-id"
CLIENT_SECRET="your-github-client-secret"
- Start the server
npm start
- POST
/user/register
- Register new user - POST
/user/login
- User login - POST
/user/logout
- User logout - POST
/user/refresh
- Refresh access token - GET
/user/auth/github
- GitHub OAuth login
- GET
/blog
- Get all blogs - POST
/blog/create
- Create new blog - PATCH
/blog/update/:blogID
- Update blog - DELETE
/blog/delete/:blogID
- Delete blog
The API uses JWT for authentication. Protected routes require a valid Bearer token:
Authorization: <your-jwt-token>
- Fork the repository
- Create your feature branch (
git checkout -b feature/amazing-feature
) - Commit your changes (
git commit -m 'feat: add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License