svelte-go-steam Svelte Themes

Svelte Go Steam

template for a svelte site using a golang & sqlite backend with steam openid

svelte-go-steam

based upon https://github.com/dresswithpockets/go-steam-openid-template

[!NOTE] see https://github.com/jump-fortress/site for a more complex example project

features

  • Steam OpenID auth flow
  • Huma api and docs with permissions middleware using sqlite3
  • migrate cli to manage sql migrations
  • sqlc to generate Go types and functions from sql
  • openapi-typescript to generate types from the apis's schema, used with openapi-fetch
  • basic example backend
  • bring your own Svelte framework! (Typescript & Tailwind are included here..)

quickstart

  1. install go 1.25
  2. reference .env.local.example to populate /api/env/.env.local
  3. install migrate and sqlc, init sqlite3 db
    cd api
    go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
    go install -tags 'sqlite3' github.com/golang-migrate/migrate/v4/cmd/migrate
    migrate -source file://db/migrations -database sqlite3://db/jump.db up
    go run .
    
  4. run Svelte site
    cd web
    npm i
    npm run dev
    

migrations

cd api
migrate create -ext sql -dir db/migrations change-summary
# move up to next migration version
migrate -source file://db/migrations -database sqlite3://db/jump.db up 1

sqlc

  1. write queries in /db/sql with sqlc's basic query annotations
  2. generate
    cd api
    sqlc generate
    

filetree

important bits of the api's filetree

  • db migrations are found in /db/migrations/
  • sql queries used with sqlc are found in /db/sql/
  • see registerRoutes() in /internal/api.go to see an example of permissions using a "dev" role
  • api routes are found in /internal/routes/routes.go
  • common data models are found in /models/
    svelte-go-steam/
    ├── api/
    │   ├── db/
    │   │   ├── migrations/
    │   │   │   ├── 20260302212745_init.down.sql
    │   │   │   └── 20260302212745_init.up.sql
    │   │   └── sql/
    │   │       ├── disallow_token.sql
    │   │       ├── openid_nonce.sql
    │   │       ├── session.sql
    │   │       ├── user.sql
    │   │       └── user_role.sql
    │   ├── env/
    │   │   ├── .env.example
    │   │   └── env.go
    │   ├── internal/
    │   │   ├── api.go
    │   │   ├── middleware.go
    │   │   ├── routes/
    │   │   │   ├── routes.go
    │   │   │   └── user.go
    │   ├── main.go
    │   ├── models/
    │   │   ├── conversions.go
    │   │   ├── errors.go
    │   │   ├── input.go
    │   │   ├── models.go
    │   │   └── output.go
    │   └── sqlc.yaml
    

Top categories

Loading Svelte Themes