pkg

package module
v0.0.0-...-1d59f67 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 14, 2024 License: MIT Imports: 0 Imported by: 0

README

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.

  1. Start a db: podman run --name db0 -e POSTGRES_USER=postgres -e POSTGRES_PASSWORD=change_me -p $(POSTGRES_TEST_PORT):5432 -d postgres:16
  2. Run either go run cmd/server/main.go or make run
  3. 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"
      }
    }
  ]
}

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
cmd
db
dbc
internal
testing/mocks
Package mocks is a generated GoMock package.
Package mocks is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL