Skip to content

JessicaFM/CodexLibris

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

📌 REST API Project with Spring Boot and JWT

This project is a REST API built with Spring Boot, using JWT for authentication and PostgreSQL as the database. The application is fully containerized with Docker.


🚀 How to Start the Project

1️⃣ Build the Docker Image

Run the following command to build the image without using cache:

docker-compose build --no-cache

2️⃣ Start the Services

docker-compose up -d

3️⃣ Check Running Containers

docker ps

🛠 Managing PostgreSQL

Check Running Services (macOS)

brew services list
brew services stop postgresql
sudo lsof -i :5432

Check Running Services (Windows)

netstat -ano | findstr :5432

🔐 HTTPS Access Notes

The API is served over HTTPS at https://localhost

Since it uses a self-signed certificate, curl commands require the -k flag to skip SSL verification

In a browser, you may need to accept the certificate manually the first time

🔥 API Endpoints

Swager

https://localhost/swagger-ui/index.html

Login

curl -X POST https://localhost/auth/login \
     -H "Content-Type: application/json" \
     -d '{"username": "admin", "password": "admin"}'
{
    "token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9...",
    "username": "admin",
    "roleId": 1
}

Users

curl -X GET https://localhost/user/1 \
     -H "Authorization: Bearer YOUR_JWT_TOKEN"
curl -X GET https://localhost/users \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"

Books

curl -X GET https://localhost:8080/books \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X GET https://localhost:8080/books/1 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X POST https://localhost:8080/books \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "title": "Watchmen (Edició Especial)",
          "authorId": 1,
          "isbn": "978-1779501127",
          "publishedDate": "1986-09-01",
          "genreId": 2,
          "available": false
         }'
curl -X PUT https://localhost:8080/books/1 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "title": "Watchmen (Edició Especial)",
          "authorId": 1,
          "isbn": "978-1779501127",
          "publishedDate": "1986-09-01",
          "genreId": 2,
          "available": false
         }'

Authors

curl -X GET https://localhost:8080/authors \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X GET https://localhost:8080/authors/1 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X POST https://localhost:8080/authors \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "name": "Alan Moore",
          "birthDate": "1953-11-18",
          "nationality": "Regne Unit"
         }'
curl -X PUT https://localhost:8080/authors/11 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "name": "Alan Moore Actualitzat",
          "birthDate": "1953-11-18",
          "nationality": "Regne Unit"
         }'

Genres

curl -X GET https://localhost:8080/genres \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X GET https://localhost:8080/genres/1 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json"
curl -X POST https://localhost:8080/genres \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "name": "Còmic",
          "description": "Històries explicades mitjançant vinyetes i diàlegs curts."
         }'
curl -X PUT https://localhost:8080/genres/5 \
     -H "Authorization: Bearer $TOKEN" \
     -H "Content-Type: application/json" \
     -d '{
          "name": "Còmic Actualitzat",
          "description": "Gènere narratiu gràfic, amb vinyetes i diàlegs curts."
         }'

About

CodexLibris API

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published