Skip to content

oaitbenh-21/01blog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

93 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog API — Endpoints Reference

This document lists the project's HTTP endpoints, what they accept and what they return.

Authentication

Posts

  • POST /posts

  • GET /posts

    • Auth: required
    • Request: none
    • Response: 200 OK JSON array of PostResponseDto
  • GET /posts/subscriptions

    • Auth: required
    • Request: none
    • Response: 200 OK JSON array of PostResponseDto — posts from users the current user follows
  • GET /posts/{id}

    • Auth: required
    • Request: URL path param id (post id)
    • Response: 200 OK JSON PostResponseDto
  • PUT /posts/{id}

    • Auth: required (must be post owner)
    • Request: PostDto (as request part)
    • Response: 200 OK PostResponseDto
  • DELETE /posts/{id}

    • Auth: required (owner or admin)
    • Response: 200 OK (empty)
  • POST /posts/{id}/like

    • Auth: required
    • Request: none
    • Response: 200 OK (empty)
    • Notes: Toggles like; creates a LIKE notification for the post owner when liked.
  • POST /posts/{id}/comment

  • DELETE /posts/{postId}/comment/{commentId}

    • Auth: required (comment owner or admin)
    • Response: 200 OK (empty)

Users

  • GET /users/{id}

  • GET /users/me

  • PUT /users/me

  • POST /users/{id}/subscribe

    • Auth: required
    • Request: path param id (user to follow)
    • Response: 200 OK (empty)
  • DELETE /users/{id}/unsubscribe

    • Auth: required
    • Request: path param id (user to unfollow)
    • Response: 200 OK (empty)

Notifications

  • GET /notifications

  • POST /notifications/{id}/read

    • Auth: required
    • Response: 200 OK (empty)
  • POST /notifications/{id}/unread

    • Auth: required
    • Response: 200 OK (empty)
  • POST /notifications/{id}/delete

    • Auth: required
    • Response: 200 OK (empty)
  • POST /notifications/markAllRead

    • Auth: required
    • Response: 200 OK (empty)

Reports

  • POST /reports/user

  • POST /reports/post

    • Auth: required
    • Request: JSON ReportRequest
    • Response: 200 OK (empty)

Admin (requires ROLE_ADMIN)

  • GET /admin/users

    • Response: 200 OK JSON array UserDto
  • GET /admin/posts

    • Response: 200 OK JSON array PostResponseDto
  • POST /admin/posts/{id}/visible

    • Response: 200 OK (empty) — toggle post visibility
  • GET /admin/reports

  • DELETE /admin/users/{id}

    • Response: 200 OK (empty)
  • DELETE /admin/users/{id}/ban

    • Response: 200 OK (empty)
  • DELETE /admin/posts/{id}

    • Response: 200 OK (empty)
  • DELETE /admin/comment/{id}

    • Response: 200 OK (empty)
  • POST /admin/reports/{id}

    • Response: 200 OK (empty) — resolve report
  • DELETE /admin/reports/{id}

    • Response: 200 OK (empty)
  • GET /admin/analytics

Notes

  • Authentication: JWT filter applied. /auth/** is public; all other endpoints require a valid JWT; /admin/** requires ROLE_ADMIN. See src/main/java/blog/Security/SecurityConfig.java.
  • DTOs and model details: Refer to files in src/main/java/blog/Dto/ and src/main/java/blog/Model/ for exact field shapes.
  • Media: Static media served under /media/** and /avatars/** (public)

If you want, I can:

  • Generate a machine-readable OpenAPI JSON/yml file.
  • Add example request/response payloads for key endpoints.
  • Add Swagger/OpenAPI integration to expose interactive docs.

About

a blog education website with spring boot

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages