This is a RESTful API for a simple blog engine developed using Spring Boot, Spring Data, Spring Security, and PostgreSQL.
- Create, read, update, and delete blog posts.
- User authentication using Basic Authentication.
- Secure password storage using Bcrypt.
- Persistent storage of blog data in a PostgreSQL database.
Make sure you have the following installed on your machine:
- Java (version 21)
- Maven
- PostgreSQL
-
Clone the repository:
git clone https://github.com/moamenhady/greatblogs-api.git
-
Build the project using Maven:
cd greatblogs-api mvn clean install
-
Configure the database connection in
src/main/resources/application.yml:url: jdbc:postgresql://localhost:5432/your_database username: your_username password: your_password
-
Configure other properties as needed (e.g., server port, logging).
java -jar target/greatblogs-api-1.2.3.jarAccess the API at http://localhost:8080/
All endpoints require user to be authenticated except /authors/signup
authors:
- POST /api/authors/signup: Sign-up a new author account with username, password and email.
- GET /api/authors/all: Retrieve all authors by username.
- GET /api/authors/{id}: Retrieve a specific author.
- PUT /api/authors/update/{id}: Update an existing author's fullName and about.
posts:
- POST /api/posts/create: Create a new blog post.
- GET /api/posts/all: Retrieve all blog posts.
- GET /api/posts/{id}: Retrieve a specific blog post.
- PUT /api/posts/update/{id}: Update an existing blog post.
- DELETE /api/posts/delete/{id}: Delete a blog post.
This API uses Basic Authentication. Include the Authorization header in your requests with the format Basic base64(username:password).
Example using curl:
curl -X GET -H "Authorization: Basic base64(username:password)" http://localhost:8080/authors/allThis project is licensed under the MIT License.