Backend service to create events, create raceclasses and assign bibs to contestants.
Supported competition formats:
in this version:
- Interval Start competition,
In next version:
- 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":"passw123"}' \
http://localhost:8082/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/events/
% curl -H "Content-Type: application/json" \
-H "Authorization: Bearer $ACCESS" \
-X POST \
--data @tests/files/event.json \
http://localhost:8080/events
% curl -H "Authorization: Bearer $ACCESS" http://localhost:8080/events
% curl -H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer $ACCESS" \
-X POST \
-F "data=@tests/files/contestants_iSonen.csv; type=text/csv" \
http://localhost:8080/events/<event-id/contestants
% curl \
-H "Authorization: Bearer $ACCESS" \
-X GET \
http://localhost:8080/events/<event-id>/contestants
Look to the openAPI specification for the details.
% pipx install nox
% pipx install poetry
% pipx inject nox nox-poetry
% git clone https://github.com/langrenn-sprint/race-service.git
% cd race-service
% pyenv install 3.12.7
% pyenv local 3.12.7 3.11.9
% poetry install
An 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=8086
DB_NAME=events_test
DB_USER=event-service
DB_PASSWORD=password
LOGGING_LEVEL=DEBUG
Start the server locally:
% poetry run adev runserver -p 8080 --aux-port 8089 event_service
% poetry run gunicorn event_service:create_app --bind localhost:8080 --worker-class aiohttp.GunicornWebWorker
To build and run the api in a Docker container:
% docker build -t ghcr.io/langrenn-sprint/event-service:latest .
% docker run --env-file .env -p 8080:8080 -d ghcr.io/langrenn-sprint/event-service:latest
The easier way would be with docker-compose:
docker-compose up --build
We use pytest for contract testing.
To run linters, checkers and tests:
% nox
To run specific test:
% nox -s integration_tests -- -k test_create_event_adapter_fails
To run tests with logging, do:
% nox -s integration_tests -- --log-cli-level=DEBUG