Presentation

Author

This project is a REST API for a blog, providing endpoints for manage the blog. It include user authentication, blog posts, comments, and file uploads. It is designed with a focus on security, performance, and scalability.

Structure of Objects
User
  • name: {first: string, last: string}
  • email: string
  • password: string
  • Role: string
  • Date Joined: Date
Blog
  • Name: {first: string, last: string}
  • Author: Identifier
  • Date of Update: Date
  • Date of Creation: Date
Post
  • title: string
  • content: string
  • Blog: Identifier
  • Last Update: Date
  • Date of Creation: Date
Comment
  • content: string
  • Post: Identifier
  • Author: Identifier
  • Date of Creation: Date

Features

  • User authentication and authorization with JWT
  • Complete error handling for all request types
  • HTTPS protocol for secure communication
  • Rate limiting to prevent abuse
  • Logging for request and error tracking
  • Pagination and caching for performance and scalability
  • Filtering and sorting support on users, posts, and comments

Endpoints Overview

Authentication & Registration

/BlogApi/v2/auth

Method Path Fields required Actions
POST /register name.last, email, password Register a new user
POST /login email, password Login user
GET /logout / Logout user

User

/BlogApi/v2/user

Method Path Fields required Actions
GET /me / Get current logged-in user
PUT /me / Update current user's password
GET /search email or firstname or role or lastname Filter users
GET / / Get all users
GET /:id / Get single user by ID
PUT /:id email or firstname or lastname Update user by ID

Blog

/BlogApi/v2/Blog

Method Path Fields required Actions
GET / / Get all blogs for online user
POST / name Create a new blog
GET /:id / Get blog by ID
PUT /:id name Update blog by ID
DELETE /:id / Delete blog by ID

Posts

/BlogApi/v2/Blog/:id/Post

Method Path Fields required Actions
GET / / Get all posts
POST / title, content Create new post
GET /me / Get posts for online author
GET /search title or author Filter posts
GET /:postid / Get single post by ID
PUT /:postid title or content Update post by ID
DELETE /:postid / Delete post by ID

Comments

/BlogApi/v2/Blog/:id/Post/:postId/comment

Method Path Fields required Actions
GET / / Get all comments
POST / content Create new comment
GET /:commentId / Get single comment by ID
DELETE /:commentId title or content Delete comment by ID

Photo Upload

/BlogApi/v2/upload

Filtering, Sorting, and Pagination

Filtering

Specific filters depend on the endpoint:

  • Users: `?email=value`, `?firstname=value`, `?role=value`, `?lastname=value`
  • Posts:`?title=value`, `?author=value`
  • Comments:`?userId=value`, `?postId=value`, `?id=value`

Sorting

  • Use `?sort=field` for ascending order
  • Use `?sort=field&desc=field` for descending order
  • Example:`?sort=name&desc=name` for descending by name

Pagination

  • Use `?page=number&limit=number` to paginate results
  • Example: `?page=1&limit=10` for page 1 with 10 items per page

Usable Fields for Sorting and Filtering

User

  • Sorting: name, First name, Last name, Email, Role, DateOfJoined
  • Filtering: email, firstname, lastname, role

Posts

  • Sorting: title, DateOfCreation, LastUpdate
  • Filtering: title, author

Comment

  • Sorting: DateOfCreation
  • Filtering: userId, postId, id