Skip to content

Repository files navigation

content-server

A web and API server for game content, user data, replays, leaderboards, and project's website.

Development Setup

Guide on how to set up your local instance of content-server.

Prerequisites

If you are working on the frontend, you will also need:

Setup

  1. Clone the repo:

    git clone https://github.com/goplease-game/content-server.git
    cd content-server
  2. Setup config:

    1. Copy config.sample.yaml to .config.yaml and edit the values. At least a DB connection is required for startup.

      Tip: It's recommended to use a _local_dev suffix for the DB name (e.g., myapp_local_dev). The reset tool uses this convention to prevent accidental data loss.

    2. Create test configurations in:
      • test/api_test/.config.yaml
      • test/service_test/.config.yaml
      • test/worker_test/.config.yaml
    3. For each test config, update the following:
      • Set a test DB connection (e.g., myapp_local_dev_test).
      • email.driver: "test"
      • tracing.enabled: false
      • files.storage_driver: "in-memory-fs"
  3. Run tests:

    go test ./...
  4. Start the server:

    go run ./cmd/server/main.go

Seeding

To populate the database with test data, use the CLI tool:

go run ./cmd/cli/main.go sd

By default, it seeds all available entities. You can specify a specific entity and count:

  • Example: go run ./cmd/cli/main.go sd users 1000 (creates 1000 users).
  • Help: go run ./cmd/cli/main.go ? sd for detailed options.

Environment Reset

If you need a clean state, run:

go run ./cmd/cli/main.go rde

This command recreates the database, applies migrations, and creates a default user.


Toolchain

templ - Live Watch & Reload

go tool templ generate --watch --proxy="http://localhost:8080" --cmd="go run ./cmd/server/main.go"

TailwindCSS - Watch

tailwindcss -i ./frontend/assets/input.css -o ./frontend/assets/output.css --watch

Linting

Requires golangci-lint

golangci-lint run

OpenAPI & Swagger

Requires swag

# Format Swagger directives
swag fmt --dir server/handler

# Generate specifications
swag init --parseDependency --parseDepth 1 --dir server/handler -g handler.go -o server/docs

About

A web and API server for game content, user data, replays, leaderboards, and project's website.

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages