This project is a Spring Boot-based REST API application for a blogging platform. It includes functionalities for managing users, categories, posts, comments, and roles. The application also includes JWT-based authentication.
- Getting Started
- Prerequisites
- Installation
- Running the Application
- API Endpoints
- Entities
- Dependencies
- License
To get a local copy of the project up and running, follow the steps below.
- Java 17 or higher
- Maven 3.6.0 or higher
- MySQL 5.7 or higher
- Clone the repository
git clone https://github.com/yourusername/blog-api.git cd blog-api
- Update the
application.properties
file in thesrc/main/resources
directory with your MySQL configurationspring.datasource.url=jdbc:mysql://localhost:3306/blogdb spring.datasource.username=root spring.datasource.password=yourpassword spring.jpa.hibernate.ddl-auto=update spring.jpa.show-sql=true
- Build the project
mvn clean install
You can run the application using the following command:
mvn spring-boot:run
The application will start on port 8080 by default.
POST /api/v1/auth/login
- Authenticate user and get JWT tokenPOST /api/v1/auth/register
- Register a new userGET /api/v1/auth/current-user
- Get the currently authenticated user
POST /api/users
- Create a new userPUT /api/users/{user_id}
- Update an existing userDELETE /api/users/{user_id}
- Delete a userGET /api/users
- Get all users with paginationGET /api/users/{user_id}
- Get a single user by ID
POST /api/categories
- Create a new categoryPUT /api/categories/{categoryId}
- Update an existing categoryDELETE /api/categories/{categoryId}
- Delete a categoryGET /api/categories
- Get all categories with paginationGET /api/categories/{categoryId}
- Get a single category by ID
POST /api/users/{user_id}/categories/{categoryId}/posts
- Create a new postPUT /api/posts/{postId}
- Update an existing postDELETE /api/posts/{postId}
- Delete a postGET /api/posts
- Get all posts with paginationGET /api/posts/{postId}
- Get a single post by IDGET /api/categories/{categoryId}/posts
- Get all posts by categoryGET /api/users/{user_Id}/posts
- Get all posts by userGET /api/posts/search/{keywords}
- Search posts by titlePOST /api/post/image/upload/{postId}
- Upload an image for a postGET /api/post/image/{imageName}
- Download an image by name
- id
- name
- password
- roles
- id
- name
- description
- id
- title
- content
- image
- createdDate
- category
- user
- id
- content
- post
- user
- id
- name
The project uses the following dependencies:
- Spring Boot Starter Data JPA
- Spring Boot Starter Web
- Spring Boot Starter Security
- Spring Boot Starter Validation
- Spring Boot DevTools
- Spring Boot Starter Test
- MySQL Connector Java
- Lombok
- MapStruct