REST-API for blog application
The application provides REST API that may be used to manage posts and comments as well as go through the registration and logging user process using a JWT token with a pagination feature included. API returns information about the number of pages and posts whilst notifying what page the user is on, including the last page. Feature for blog users to like and unlike posts and comments has been added aswell.
Java 18
Spring Boot 5
Spring Security 5
Hibernate
Maven
Tomcat
MySQL
Lombok
DevTools
JWT token
ModelMapper
Liquibase
Swagger
Posts Management - create, delete, update display all or single post
Comments Management - create, delete, update display all or single comment
Comments Management - create, delete, update display all or single comment
Likes Management - giving likes to posts and comments with unlike function
Method
Url
Decription
Sample Body
POST
/api/v1/auth/signup
Sign up
JSON
POST
/api/v1/auth/signin
Log in
JSON
Method
Url
Description
Sample Body
GET
/api/v1/posts
Get all posts
JSON
GET
/api/v1/posts/{id}
Get post by id
JSON
POST
/api/v1/posts
Create new post
JSON
PUT
/api/v1/posts/{id}
Update post
JSON
DELETE
/api/v1/posts/{id}
Delete post
JSON
DELETE
/api/v1/posts/{id}/like
Unlike post
JSON
PATCH
/api/v1/posts/{id}/like
Like post
JSON
Comments
Method
Url
Description
Sample Body
GET
/api/v1/posts/{postId}/comments
Get all comments
JSON
GET
/api/v1/posts/{postId}/comments/{id}
Get comment by id
JSON
POST
/api/v1/posts/{postId}/comments
Create new post
JSON
PUT
/api/v1/posts/{postId}/comments/{id}
Update post
JSON
DELETE
/api/posts/{postId}/comments/{id}
Delete post
JSON
Test them using postman or any other rest client.
Sample JSON Request/Reponse
{
"password" : " string" ,
"username" : " string" ,
"age" : 0 ,
"email" : " string" ,
"gender" : " FEMALE" ,
"name" : " string"
}
{
"usernameOrEmail" : " string" ,
"password" : " string"
}
{
"content" : [
{
"comments" : [
{
"body" : " string" ,
"email" : " string" ,
"name" : " string"
}
],
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
],
"last" : true ,
"pageNo" : 0 ,
"pageSize" : 0 ,
"totalElements" : 0 ,
"totalPages" : 0
}
{
"comments" : [
{
"body" : " string" ,
"email" : " string" ,
"name" : " string"
}
],
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
{
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
{
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
{
Post deleted successfully.
}
{
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
[
{
"body" : " string" ,
"email" : " string" ,
"name" : " string"
}
]
{
"body" : " string" ,
"email" : " string" ,
"name" : " string"
}
{
"body" : " string" ,
"email" : " string" ,
"name" : " string"
}
{
"content" : " string" ,
"description" : " string" ,
"title" : " string"
}
{
Comment deleted successfully.
}