Skip to content

DamiAjele/Blog-API

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📰 Blog API

A RESTful API built with Express for managing blog posts, categories, and comments.This project was built to focus on authentication, CRUD operations, and relational data management.

🚀 Features

  • User authentication (JWT-based login/register)
  • CRUD operations for blog posts
  • Categories and tags support
  • Comment system (linked to blog posts & users)
  • Erro handling

🛠 Tech Stack

  • Node.js + Express.js
  • MongoDB + Mongoose
  • JWT for authentication
  • Multer / Cloudinary for image uploads
  • Postman for API testing

📂 Project Structure

blog-api/
│ ├── controllers/ # Request handlers
│ ├── models/ # Mongoose schemas
│ ├── config/ # for configurations
│ ├── routes/ # Express routes
│ ├── middlewares/ # Authentication
│ ├── utils/ # Helpers (e.g. Cloudinary upload)
│── .env
│── index.js
│── package.json
│── README.md

🔑 Authentication

  • Register with POST /api/users/authentication/register
  • Login with POST /api/users/authentication/login

📘 API Documentation

Detailed Postman docs here 👉 View Postman Documentation

🛠 Installation

# Clone repo
git clone https://github.com/DamiAjele/Blog-API.git
cd blog-api

# Install dependencies
npm install

# Create .env file
MONGO_URI=your_mongo_connection
JWT_SECRET=your_jwt_secret
PORT=5000

# Run server
npm run start

🔍 Usage

Example request to create a blog post:

POST /api/posts/create-post Authorization: Log in (JWT-based) Content-Type: application/json

{
  "title": "My First Blog Post",
  "content": "This is the content of the blog",
  "category": "Technology"
}

Future Improvments

  • Pagination, filtering and sorting of blog posts

Error Handling

The API includes proper error handling for:

  • Non-existent users, posts, categories, and comments
  • Invalid users and posts IDs
  • Malformed requests

Author

Damilola Ajele

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published