Getting Started
Ensure you have the latest version of these dependencies installed. The libraries will be fetched by go automatically.
Run Tests
To test everything, run gotip test ./...
or make test
from ./backend
. There is also a helper script: ./test.sh
that sets up a container for the tests.
Hacking
To run the backend, create a local database container, then migrate up.
- Start a db:
podman run --name db0 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=change_me -p $(POSTGRES_TEST_PORT):5432 -d postgres:16
- Run either
go run cmd/server/main.go
or make run
- Open http://localhost:4011/playground
Sqlc
Sqlc interprets sql files and generates the database api. Queries are no longer stored in strings or runes in the code.
Install with a package manager like pacman -S sqlc
or grab the tool from the sqlc docs, then unzip.
curl -L -o sqlc_1.18.0_linux_amd64.tar.gz https://github.com/kyleconroy/sqlc/releases/download/v1.18.0/sqlc_1.18.0_linux_amd64.tar.gz
tar -xf sqlc_1.18.0_linux_amd64.tar.gz .
sudo mv sqlc /usr/bin/sqlc
chmod +x /usr/bin/sqlc
GraphQL Backend Server
Relies on gqlgen which is a schema-first approach to GraphQL servers.
Run the backend server
Run PLAYGROUND=true gotip run ./services/server/main.go
from ./backend
. Using PLAYGROUND=true
enables the graphql playground
Development
The following are helpful commands for working with the project.
Code Generation
Run go generate ./...
from the ./backend
folder.
Debugging with VSCode
Create a launch.json
file and add this. This will enable debugging of your server.
{
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Debug Server",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "cmd/main.go",
"env": {
"PLAYGROUND": "true"
}
}
]
}