A RESTful API for managing blogs with user authentication. This API allows users to create, read, update, and delete blog posts, while ensuring only authenticated users have access to the blog-related functionality. User registration and login are secured using JWT tokens for authentication.
Server: Node.js, Express.js
Database: MongoDB
ODM Tool: Mongoose
Authentication: JWT (JSON Web Token)
Password Security: bcrypt.js for password hashing
- User Management: Endpoints for user registration, login, and profile access.
- Blog Management: Endpoints for creating, reading, updating, and deleting blog posts.
- JWT Authentication: Secure access to blog routes using JWT tokens.
- Protected Routes: Only authenticated users can create, update, or delete blog posts.
- Error Handling: Graceful error handling for all endpoints.
To run this project, you will need to add the following environment variables to your .env file:
PORT=<Your preferred port number>
MONGO_URI=<Your MongoDB connection string>
JWT_SECRET=<Your secret key for JWT>- Clone the project
https://github.com/sanjithrk06/Blog-Platform.git- Go to the project directory
cd Blog-Platform- Install dependencies
npm install-
Create a .env file
Add the required environment variables as shown above.
-
Start the server
npm run startThe server will start on the port you specified in the .env file or on port 3000 by default.
| Method | End Point | Description | |
|---|---|---|---|
| Signup | POST | /auth/signup |
Register a new user |
| Login | POST | /auth/login |
Log in an existing user |
| Method | End Point | Description |
|---|---|---|
| GET | /blog |
Get all blogs |
| POST | /blog |
Create a new blog |
| PUT | /blog/:id |
Update a blog |
| DELETE | /blog/:id |
Delete a blog |
For protected routes, include the JWT token in the headers:
{
"Authorization": "Bearer <your-jwt-token>"
}This project is licensed under the MIT License. You are free to use, modify, and distribute it as you see fit.