The Book Library API is a RESTful API built using Go, Fiber, Postgres SQL, and Slog for logging. The API manages a collection of books and keeps track of a user's progress with each book. Authentication is handled using Auth0.
- Create, read, update, and delete books
- Register and login users
- Add and update progress for a user and book
- Authentication using Auth0
- Go 1.19
- Fiber 2.23
- Postgres SQL 14.2
- Slog 1.8
- Auth0
- Go 1.19 or higher
- Postgres SQL 14.2 or higher
- Auth0 account (to-be-added)
- Clone the repository: `git clone (https://github.com/jvanrhyn/bookshelf)
- Create a Postgres database and update the
database.yml
file with your credentials - Run
go mod download
to download dependencies - Run
go run main.go
to start the API
Your application requires several environment variables to function correctly. These variables should be added to
a .env
file in the root directory of your project.
The required environment variables are:
DB_USER
: The username for your Postgres database.DB_PASS
: The password for your Postgres database.DB_NAME
: The name of your Postgres database.DB_HOST
: The host of your Postgres database.DB_PORT
: The port of your Postgres database.AUTH0_DOMAIN
: Your Auth0 domain.AUTH0_CLIENT_ID
: Your Auth0 client ID.AUTH0_CLIENT_SECRET
: Your Auth0 client secret.
Here is a sample .env
file:
POST /books
: Create a new bookGET /books/:id
: Retrieve a book by IDGET /books/isbn/:isbn
: Retrieve a book by ISBNPUT /books/:id
: Update a bookDELETE /books/:id
: Delete a bookPOST /users
: Register a new userPOST /login
: Login a userGET /users/:id
: Retrieve a user's profileGET /users/email/:email
: Retrieve a user's profile by emailPOST /progress
: Add a new progress entryGET /progress/:book_id
: Retrieve a user's progress for a bookPUT /progress/:book_id
: Update a user's progress for a book
- Use the
Authorization
header with a valid Auth0 token to authenticate requests
Contributions are welcome! Please open a pull request with your changes.
MIT License