📄 API Specs
GET
HTTP Method | Use | Endpoint |
---|---|---|
GET | Index all books | /books |
GET | Show book by id | /books/{id} |
GET | Index books by title or author | /books?search=foo |
GET | Index books with custom limit | /books?limit=5 |
GET | Paginate books | /books?limit=5&page=3 |
POST | Create new book | /books |
PUT | Update book | /books/{id} |
DELETE | Destroy book | /books/{id} |
⚙️ Setting Up
💻
Local Prerequisites:
- .NET 5.0
- PostgreSQL
Running the api locally
-
Copy and set up enviroment variables for the database
cp .env.example .env
-
Run the app on your local port
dotnet watch run --project ./src/BookApi.csproj
Running the tests
-
Run the tests
cd tests
dotnet test
🐳
Docker Prerequisites:
- Docker
Running the containers
-
Copy environment variables for the database
cp .env.example .env
-
Build docker images
docker compose build
-
Run docker containers
docker compose up
Running the tests
-
Run the tests in the api container
docker compose exec api /bin/sh -c "cd tests; dotnet test;"