The Blog Manager API is a Spring Boot application that provides RESTful endpoints for managing users and posts in a blogging platform.
- Java 17+
- Maven
- PostgreSQL
Update the src/main/resources/application.properties file with your database credentials:
spring.datasource.url=jdbc:postgresql://localhost:5432/your_database
spring.datasource.username=your_username
spring.datasource.password=your_passwordThe API documentation is available through Swagger UI:
- URL: http://localhost:8080/swagger-ui/index.html
- OpenAPI JSON: http://localhost:8080/v3/api-docs
This interactive documentation allows you to explore and test all available endpoints directly from your browser.
Base URL: /api/v1/user
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
GET |
/api/v1/user |
Get all users | N/A |
GET |
/api/v1/user/{id} |
Get a user by ID | N/A |
POST |
/api/v1/user/register |
Register a new user | JSON representation of a User object |
POST |
/api/v1/user/login |
Login a user | JSON representation of a User object |
PUT |
/api/v1/user/{id} |
Update an existing user by ID | JSON representation of a User object |
DELETE |
/api/v1/user/{id} |
Delete a user by ID | N/A |
Base URL: /api/v1/posts
| Method | Endpoint | Description | Request Body |
|---|---|---|---|
GET |
/api/v1/posts |
Get all posts | N/A |
GET |
/api/v1/posts/{id} |
Get a post by ID | N/A |
GET |
/api/v1/posts/user/{id} |
Get all posts by a specific user | N/A |
POST |
/api/v1/posts |
Create a new post | JSON representation of a Post object |
PUT |
/api/v1/posts/{id} |
Update an existing post by ID | JSON representation of a Post object |
DELETE |
/api/v1/posts/{id} |
Delete a post by ID | N/A |
{
"username": "johndoe",
"password": "password123"
}{
"title": "My First Blog Post",
"content": "This is the content of the blog post.",
"user_id": 1
}- Clone the repository.
- Build the project using Maven:
./mvnw clean install
- Run the application:
./mvnw spring-boot:run
- Access the API at http://localhost:8080
- View the API documentation at http://localhost:8080/swagger-ui/index.html
Run the tests using Maven:
./mvnw testCreate an optimized build:
./mvnw clean package -P productionThis project is licensed under the MIT License.