Skip to content

A simple books RESTful API, made with ASP.NET Core, Dapper ORM for a PostgreSQL database.

Notifications You must be signed in to change notification settings

lucaxue/book-api

Repository files navigation

📚 Books REST API

ASP.NET Core PostgreSQL Dapper ORM
xUnit FluentAssertions NSubstitute

A simple REST API, following repository pattern for a books table.


📄 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

  1. Copy and set up enviroment variables for the database

    cp .env.example .env
  2. Run the app on your local port

    dotnet watch run --project ./src/BookApi.csproj

Running the tests

  1. Run the tests

    cd tests
    dotnet test

Docker 🐳

Prerequisites:

  • Docker

Running the containers

  1. Copy environment variables for the database

    cp .env.example .env
  2. Build docker images

    docker compose build
  3. Run docker containers

    docker compose up

Running the tests

  1. Run the tests in the api container

    docker compose exec api /bin/sh -c "cd tests; dotnet test;"

About

A simple books RESTful API, made with ASP.NET Core, Dapper ORM for a PostgreSQL database.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published