Skip to content

sanjithrk06/Blog-Platform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 Variables

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>

Run Locally

  1. Clone the project
  https://github.com/sanjithrk06/Blog-Platform.git
  1. Go to the project directory
  cd Blog-Platform
  1. Install dependencies
  npm install
  1. Create a .env file

    Add the required environment variables as shown above.

  2. Start the server

  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:

{
  "Authorization": "Bearer <your-jwt-token>"
}

License

This project is licensed under the MIT License. You are free to use, modify, and distribute it as you see fit.


About

A RESTful API for managing blogs with user authentication.

Topics

Resources

License

Stars

0 stars

Watchers

1 watching

Forks

Contributors