Skip to content

Complete Backend Api for a Blog Application in SpringBoot with JWT Authentication, Also Configured with Swagger for Api Documentation.

Notifications You must be signed in to change notification settings

Definite17/blog-app-apis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Blog Application

Complete Backend Api for a Blog Application in SpringBoot with JWT Authentication, Also having configuration with Swagger-ui for Api Documentation.

Api Enpoints

This projects consists Enpoints for:-

1) Login and Registering a User.

a) createToken

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

b) registerUser

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"
    }
  ]
}

2) User API's

All CRUD API's for user.

a) createUser

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"
    }
  ]
}

b) updateUser

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"
    }
  ]
}

c) deleteUser

API for deleting existing user.

DELETE /api/users/{userId}
Parameter Type Description
userId Integer Required. ID of the User you want to DELETE

d) getUserById

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

e) getAllUsers

API for getting All user details.

GET /api/users

3)Posts API's

API related to all the Post's in the BLOG

a) createPost

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"
      }
    ]
  }
}

b) updatePost

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"
      }
    ]
  }
}

c) deletePost

API for deleting a Post.

DELETE api/posts/post/{postId}
Parameter Type Description
postId Integer Required. ID of the Post you want to DELETE

d) uploadPostImage

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

e) getPostById

API to get a post with its ID.

GET /api/posts/{postId}

Required Parameter :- postId

f) getAllPost

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

g) getPostByCategory

API to get Posts of a particular category.

GET /api/posts/category/{categoryId}

Optional Parameters :- pageSize, pageNumber, sortBy, sortDir

h) downloadImage

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.

i) searchPostByTitle

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.
j) getPostByUser

API to get All posts of a particular user.

GET /api/posts/user/{userId}

Required Parameter : userId.

Optional Parameter : pageSize, pageNumber, sortBy, sortDir

4) Category API's

API related to the Categories of the Posts.

a) createCategory

API to add/create a category.

POST /api/categories/create

Required Request Body:- CategoryDto

{
  "categoryDescription": "string",
  "categoryId": 0,
  "categoryTitle": "string"
}

b) updateCategory

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

c) deleteCategory

API to delete a Category.

DELETE /api/categories/{categoryId}

Required Parameter:- categoryId

d) getAllCategory

API to get ALL Categories.

GET /api/categories
e) getCategoryById

API to get a Category by its ID.

GET /api/categories/{categoryId}

Required Parameter:- categoryId

5) Comments API's

API's Related to comments.

a) createComment

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.

About

Complete Backend Api for a Blog Application in SpringBoot with JWT Authentication, Also Configured with Swagger for Api Documentation.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages