README.md

February 3, 2026 · View on GitHub

Test

Run all tests in the project.

$ go test ./...

查看测试覆盖率(仅统计 server + model,目标 ≥80%):

$ go test ./server/ ./model/ -coverprofile=coverage.out -coverpkg=./server/...,./model/...
$ go tool cover -func=coverage.out

Run dev mysql with docker

Start a MySQL container for local development; maps host port 3306 to the container.

$ docker run --name mysql-dev -p 3306:3306 -e MYSQL_ROOT_PASSWORD=root123456 -e MYSQL_DATABASE=dev -e MYSQL_USER=dev -e MYSQL_PASSWORD=123456 -d mysql

Run DEFI indexer

Run the DEFI data indexer in a container. Ensure MySQL is reachable (e.g. via "Run dev mysql with docker" above) before starting.

$ docker run --name wquery3-database --restart always \
  -e DB_USERNAME=dev \
  -e DB_PASSWORD=123456 \
  -e DB_HOST=127.0.0.1 \
  -e DB_NAME=dev \
  -e DB_PORT=3306 \
  -e API_KEY=8d6080e3d9c214680a8543a1a29758c9 \
  --network host \
  --entrypoint /bin/bash \
  wetee/query_web3_database:2026-01-21-16_33 \
  -c "python CAO/all_data_jobs.py"

Run with go

Create your local env file from the example, then start the backend server. Content of .env.example:

DB_DSN="dev:123456@tcp(127.0.0.1:3306)/dev?charset=utf8mb4&parseTime=True&loc=Local"
PORT=8082

Copy the example file and run the server:

$ cp .env.example .env

$ go run server/server.go

Use API

Health Check

GET /health 用于健康检查(如 Docker/K8s 探针),返回 JSON:

  • 200:服务与数据库正常,例如 {"status":"ok","db":"ok"}
  • 503:数据库不可用,例如 {"status":"unhealthy","db":"unhealthy"}
curl http://localhost:8082/health

Using GraphQL Playground

Open http://0.0.0.0:8082/ in your browser to use the GraphQL Playground (after the server is running).