TWHelp core code repository. https://twhelp.app/api/v1/swagger/index.html
This repository has been archived on 2024-04-06. You can view files and clone it, but cannot push or open issues or pull requests.
Go to file
Dawid Wysokiński 2faa7fb6a2
chore: update README.md [skip ci]
2024-04-06 06:28:19 +02:00
.woodpecker chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
build/docker chore(deps): update golang docker tag to v1.21.6 (#255) 2024-01-13 08:48:43 +00:00
cmd/twhelp refactor: adapters - rename structs/files 2023-07-22 08:22:28 +02:00
docs chore: update README.md (#141) 2022-12-20 08:10:10 +00:00
internal chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
k8s feat: use goose as a db migration tool (#226) 2023-06-10 06:21:07 +00:00
migrations feat: use goose as a db migration tool (#226) 2023-06-10 06:21:07 +00:00
.commitlintrc.yml init 2022-07-24 14:06:31 +02:00
.dockerignore chore: update .dockerignore 2022-09-30 07:40:16 +02:00
.envrc init 2022-07-24 14:06:31 +02:00
.gitignore init 2022-07-24 14:06:31 +02:00
.golangci.yml chore: update deps 2023-06-08 07:32:30 +02:00
.pre-commit-config.yaml chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
LICENSE init 2022-07-24 14:06:31 +02:00
Makefile chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
README.md chore: update README.md [skip ci] 2024-04-06 06:28:19 +02:00
go.mod chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
go.sum chore: bump deps (#252) 2023-10-30 08:25:29 +00:00
renovate.json chore: update renovate config [skip ci] 2023-04-30 06:18:34 +02:00
skaffold.yml chore: bump deps (#252) 2023-10-30 08:25:29 +00:00

README.md

[DEPRECATED] Active at https://gitea.dwysokinski.me/twhelp/core

core

TWHelp is a project aiming to provide:

  1. Easy access to Tribal Wars data, for both users and developers.
  2. Scripts & tools to facilitate gameplay.

Getting started

Development

Setting up the environment

Prerequisites:

  1. Go (>= 1.19)
  2. Node.js (LTS, needed for commitlint)
  3. Kubernetes (>= 1.25.0)
    1. minikube
    2. Docker Desktop
  4. Docker CLI
  5. Skaffold
  6. pre-commit
  7. IDE/Code editor (e.g. Goland, VSCode, vim, neovim)
  8. direnv (optional, but recommended)
# if you have direnv installed
direnv allow

# install git hooks and required tools
make install

# run all required services
skaffold run --port-forward=true --tail=true

# stop all of them
skaffold delete

Running unit tests

At least one of the following is required to run unit tests:

  • Docker (dockertest will spin up a database)
  • Postgres database
# Docker
go test -v ./...

# Postgres database
TESTS_DB_DSN=postgres://twhelp:twhelp_pass@127.0.0.1/twhelp go test -v ./... 

Creating a new database migration

# create a migration
go run ./cmd/twhelp/main.go db create go migration 1

img.png

Configuration options

Configuration options can be specified via environment variables.

Env variable Default Description
APP_MODE development Whether to use development or production settings
DB_DSN Required. Only Postgres is supported. Example: postgres://user:password@host:5432/dbname?sslmode=disable (https://www.postgresql.org/docs/current/libpq-connect.html#LIBPQ-CONNSTRING)
DB_MAX_OPEN_CONNECTIONS 5 Maximum number of open connections to the database (https://pkg.go.dev/database/sql#DB.SetMaxOpenConns)
DB_MAX_IDLE_CONNECTIONS 2 Maximum number of connections in the idle connection pool (https://pkg.go.dev/database/sql#DB.SetMaxIdleConns)
DB_CONNECTION_MAX_LIFETIME 3m Maximum amount of time a connection may be reused (https://pkg.go.dev/database/sql#DB.SetConnMaxLifetime)
AMQP_URI Required. Example: amqp://user:password@host:5672/ (https://www.rabbitmq.com/uri-spec.html)
AMQP_PREFETCH_COUNT 2 https://www.rabbitmq.com/consumer-prefetch.html
API_SWAGGER_ENABLED false Enables the API documentation endpoints (e.g. /api/v1/swagger/index.html, /api/v1/swagger/doc.json)
API_SWAGGER_HOST Host (name or ip) serving the API (e.g. tribalwarshelp.com)
API_SWAGGER_SCHEMES http,https Comma-separated list of protocols
API_CORS_ENABLED false Enables CORS headers
API_CORS_ALLOWED_ORIGINS Comma-separated list of allowed domains
API_CORS_ALLOW_CREDENTIALS false Whether requests with credentials are allowed
API_CORS_ALLOWED_METHODS HEAD,GET Comma-separated list of allowed methods
API_CORS_MAX_AGE 300 Max time to cache response (seconds)

License

Distributed under the MIT License. See LICENSE for more information.

Contact

Dawid Wysokiński - contact@dwysokinski.me