Complete Backend Api for a Blog Application in SpringBoot with JWT Authentication, Also having configuration with Swagger-ui for Api Documentation.
This projects consists Enpoints for:-
User will need to Log in with his email as username(email) and password and JWTAuthentication token will be generated for him.
POST /api/v1/auth/login
User Will be Registered and "ROLE_NORMAL" would be given to him, where he will be
POST /api/v1/auth/register
Required RequestBody : UserDto
{
"about": "string",
"email": "string",
"id": 0,
"name": "string",
"password": "string",
"roles": [
{
"id": 0,
"name": "string"
}
]
}
All CRUD API's for user.
API for adding user.
POST /api/users/create
Required RequestBody : UserDto
{
"about": "string",
"email": "string",
"id": 0,
"name": "string",
"password": "string",
"roles": [
{
"id": 0,
"name": "string"
}
]
}
API for updating user Details.
PUT /api/users/{userId}
Parameter | Type | Description |
---|---|---|
userId |
Integer |
Required. ID of the User you want to UPDATE |
Required RequestBody : UserDto
{
"about": "string",
"email": "string",
"id": 0,
"name": "string",
"password": "string",
"roles": [
{
"id": 0,
"name": "string"
}
]
}
API for deleting existing user.
DELETE /api/users/{userId}
Parameter | Type | Description |
---|---|---|
userId |
Integer |
Required. ID of the User you want to DELETE |
API for getting user Deatils by userId.
GET /api/users/{userId}
Parameter | Type | Description |
---|---|---|
userId |
Integer |
Required. ID of the User you want to GET |
API for getting All user details.
GET /api/users
API related to all the Post's in the BLOG
API for creating a new Post
POST /api/posts/user/{userId}/category/{categoryId}/create
Parameter | Type | Description |
---|---|---|
userId |
Integer |
Required. ID of the User. |
categoryId |
Integer |
Required. ID of the Category |
Required RequestBody : PostDto
{
"category": {
"categoryDescription": "string",
"categoryId": 0,
"categoryTitle": "string"
},
"comments": [
{
"content": "string",
"id": 0
}
],
"content": "string",
"createdAt": "2022-10-25T14:14:03.896Z",
"imgName": "string",
"postId": 0,
"title": "string",
"user": {
"about": "string",
"email": "string",
"id": 0,
"name": "string",
"roles": [
{
"id": 0,
"name": "string"
}
]
}
}
API for updating the Post
PUT /api/posts/update/{postId}
Parameter | Type | Description |
---|---|---|
postId |
Integer |
Required. ID of the Post you want to UPDATE |
Required RequestBody : PostDto
{
"category": {
"categoryDescription": "string",
"categoryId": 0,
"categoryTitle": "string"
},
"comments": [
{
"content": "string",
"id": 0
}
],
"content": "string",
"createdAt": "2022-10-25T14:14:03.896Z",
"imgName": "string",
"postId": 0,
"title": "string",
"user": {
"about": "string",
"email": "string",
"id": 0,
"name": "string",
"roles": [
{
"id": 0,
"name": "string"
}
]
}
}
API for deleting a Post.
DELETE api/posts/post/{postId}
Parameter | Type | Description |
---|---|---|
postId |
Integer |
Required. ID of the Post you want to DELETE |
API for uploading image to the Corresponding Post
POST api/posts/post/image/upload/{postId}
Parameter | Type | Description |
---|---|---|
postId |
Integer |
Required. ID of the Post in which you want to Upload Image |
image |
multipart/form-data |
Required Image file you want to upload |
API to get a post with its ID.
GET /api/posts/{postId}
Required Parameter :- postId
API to get all posts.
GET /api/posts/all
Optional Parameters
Parameter | Type | Description |
---|---|---|
pageSize |
Integer |
Size of the page you want |
pageNumber |
Integer |
Page Number you want to look in |
sortBy |
String |
property with which you want to SORT, eg: (postId), Default value: postId |
sortDir |
String |
The Direction in which you want to sort, eg: "DSC" for descending Order. Default value: asc |
API to get Posts of a particular category.
GET /api/posts/category/{categoryId}
Optional Parameters :- pageSize, pageNumber, sortBy, sortDir
API to View/Download image of a Post.
GET /api/posts/post/image/{imageName}
Required Parameter
Parameter | Type | Description |
---|---|---|
imageName |
String |
Required. Name of the Image to want. |
API to search Post By Title
GET /api/posts/search/{keywords}
Required Parameter
Parameter | Type | Description |
---|---|---|
keywords |
String |
Required. Full Title or some words of the title. |
API to get All posts of a particular user.
GET /api/posts/user/{userId}
Required Parameter : userId.
Optional Parameter : pageSize, pageNumber, sortBy, sortDir
API related to the Categories of the Posts.
API to add/create a category.
POST /api/categories/create
Required Request Body:- CategoryDto
{
"categoryDescription": "string",
"categoryId": 0,
"categoryTitle": "string"
}
API to update a category.
PUT /api/categories/{categoryId}
Parameter | Type | Description |
---|---|---|
categoryId |
Integer |
Required. Id of the Catgeory you want to UPDATE. |
Required Request Body:- CategoryDto
API to delete a Category.
DELETE /api/categories/{categoryId}
Required Parameter:- categoryId
API to get ALL Categories.
GET /api/categories
API to get a Category by its ID.
GET /api/categories/{categoryId}
Required Parameter:- categoryId
API's Related to comments.
API to create Comment.
POST /api/comments/{postId}/create
Required Parameter:- postId
Required Request Body:- CommentDto
{
"content": "string",
"id": 0
}
b) deleteComment API to delete a Comment.
DELETE /api/comments/delete/{commentId}/
Parameter | Type | Description |
---|---|---|
commentId |
Integer |
Required. Id of the Comment you want to DELETE. |