Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sanjithrk06/blog-platform
A RESTful API for managing blogs with user authentication.
https://github.com/sanjithrk06/blog-platform
expressjs jwt-authentication mongodb nodejs rest-api
Last synced: 6 days ago
JSON representation
A RESTful API for managing blogs with user authentication.
- Host: GitHub
- URL: https://github.com/sanjithrk06/blog-platform
- Owner: sanjithrk06
- License: mit
- Created: 2024-09-22T09:47:58.000Z (4 months ago)
- Default Branch: main
- Last Pushed: 2024-11-14T01:21:32.000Z (2 months ago)
- Last Synced: 2025-01-21T16:13:08.298Z (6 days ago)
- Topics: expressjs, jwt-authentication, mongodb, nodejs, rest-api
- Language: JavaScript
- Homepage:
- Size: 21.5 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# **Blog Platform(RESTful API)**
## Project Overview
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.
---
## Tech Stack**Server:** Node.js, Express.js
**Database:** MongoDB
**ODM Tool:** Mongoose
**Authentication:** JWT (JSON Web Token)
**Password Security:** bcrypt.js for password hashing
---
## Key features- **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.---
## Environment VariablesTo run this project, you will need to add the following environment variables to your .env file:
```env
PORT=
MONGO_URI=
JWT_SECRET=
```---
## Run Locally1. **Clone the project**
```bash
https://github.com/sanjithrk06/Blog-Platform.git
```2. **Go to the project directory**
```bash
cd Blog-Platform
```3. **Install dependencies**
```bash
npm install
```4. **Create a .env file**
Add the required environment variables as shown above.
5. **Start the server**
```bash
npm run start
```The server will start on the port you specified in the .env file or on port 3000 by default.
---
## API Documentation#### Auth Routes
| | Method | End Point | Description |
| :--------- | :------- | :------------- | :---------------------- |
| **Signup** | **POST** | `/auth/signup` | Register a new user |
| **Login** | **POST** | `/auth/login` | Log in an existing user |#### Blog Routes
| 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 |#### Request Headers
For protected routes, include the JWT token in the headers:
```json
{
"Authorization": "Bearer "
}
```---
## LicenseThis project is licensed under the MIT License. You are free to use, modify, and distribute it as you see fit.
---