A simple quest-tracking API built with Go, Chi, and PostgreSQL. This project focuses on separated layers by decoupling components, and using dependency injection (through the use of closures), to enhance maintainability and scalability. It supports basic CRUD operations for managing quest data via an HTTP server and uses Docker Compose for service orchestration.
Commit history includes multiple changes to the code.
TBD
- Docker
- Docker Compose
- Go (1.22+ recommended)
- Go Migrate - (required for database migrations)
This server uses a .env
file for basic configuration.
See .env.example
for an example .env
file.
The makefile
requires the environment file to be named ".env" to function properly. Rename the .env.example
file to .env
.
- Clone this repository:
git clone https://github.com/travboz/gorm-to-postgres-refactor.git cd gorm-to-postgres-refactor
- Run docker container:
make compose-up
- Run database migrations:
make migrate/up
- Start server:
make run
- Navigate to
http://localhost:8000
and call an endpoint
- Clone this repository:
git clone https://github.com/travboz/gorm-to-postgres-refactor.git cd gorm-to-postgres-refactor
- Start server (runs compose, and migrations):
make quick-run
- Navigate to
http://localhost:8000
and call an endpoint
Method | Endpoint | Description |
---|---|---|
GET |
/quests |
Retrieve all quests in the game |
GET |
/quests/:id |
Fetch a quest by its ID |
POST |
/quests |
Create a new quest in the game |
PUT |
/quests/:id |
Update a quest with the specified ID |
DELETE |
/quests/:id |
Delete a quest with the specified ID |
TBD
Feel free to fork and submit PRs!
MIT
This should work for GitHub! Let me know if I can make any tweaks.
Image by Egon Elbre, used under CC0-1.0 license.