Backend service to administrate competition formats.
Supported competition formats:
in this version:
- Interval Start competition,
- Individual sprint competition without a qualification round.
In future versions:
- Mass start competition,
- Skiathlon competition,
- Pursuit,
- Individual sprint competition with a qualification round,
- Team sprint competition, and
- Relay competitions.
% curl -H "Content-Type: application/json" \
-X POST \
--data '{"username":"admin","password":"password"}' \
http://localhost:8081/login
% export ACCESS="" #token from response
% curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS" \
-X POST \
--data @tests/files/competition_format_individual_sprint.json \
http://localhost:8080/competition-formats
% curl http://localhost:8080/competition-formats # list all competition formats
% curl "http://localhost:8080/competition-formats?name=Individual%20Sprint" # search competition format by name
% curl http://localhost:8080/competition-formats/<the_id> # get competition format by id
% % curl \
-H "Authorization: Bearer $ACCESS" \
-X DELETE \
http://localhost:8080/competition-formats/<the_id>Look to the openAPI specification for the details.
Start the server locally:
% uv run --env-file=.env fastapi dev% uv run --env-file=.env uvicorn app:api --host 0.0.0.0 --port 8000 --reload --log-config=logging.yamlTo build and run the api in a Docker container:
% docker build -t ghcr.io/langrenn-sprint/competition-format-service:latest .
% docker run --env-file .env -p 8080:8080 -d ghcr.io/langrenn-sprint/competition-format-service:latestThe easier way would be with docker compose:
% docker compose up --buildWe use pytest for contract testing.
To run linters, checkers and tests:
% uv run poe releaseTo run specific test:
% uv run poe integration-test --no-cov -- tests/integration/test_competition_formats.py::test_create_competition_format_interval_startTo run tests with logging, do:
% uv run poe integration-test --log-cli-level=DEBUGAn example .env file for local development:
JWT_SECRET=secret
JWT_EXP_DELTA_SECONDS=3600
ADMIN_USERNAME=admin
ADMIN_PASSWORD=password
USERS_HOST_SERVER=localhost
USERS_HOST_PORT=8081
DB_USER=competition-format-service
DB_PASSWORD=password
LOGGING_LEVEL=DEBUG% py3clean .