Skip to content

langrenn-sprint/event-service

Repository files navigation

event-service

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.

Usage example

Docs available at http://localhost:8000/docs when running the API locally.

% 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:8082/competition-formats
% curl -H "Content-Type: application/json" \
  -H "Authorization: Bearer $ACCESS" \
  -X POST \
  --data @tests/files/event.json \
  http://localhost:8000/events
% curl -H \
  -X GET \
  http://localhost:8000/events
% curl -H "Content-Type: multipart/form-data" \
  -H "Authorization: Bearer $ACCESS" \
  -X POST \
  -F "file=@tests/files/contestants_iSonen.csv; type=text/csv" \
  http://localhost:8000/events/<event-id>/contestants/file
% curl \
  -X GET \
  http://localhost:8000/events/<event-id>/contestants
% curl \
  -H "Authorization: Bearer $ACCESS" \
  -X POST \
  http://localhost:8000/events/<event-id>/generate-raceclasses
% curl \
  -X GET \
  http://localhost:8000/events/db781aab-0dd3-46cb-9de0-118b957e2a4a/raceclasses
% curl \
  -X GET \
  "http://localhost:8000/events/db781aab-0dd3-46cb-9de0-118b957e2a4a/raceclasses?raceclass-name=J11"
% curl \
  -X GET \
  "http://localhost:8000/events/db781aab-0dd3-46cb-9de0-118b957e2a4a/raceclasses?ageclass-name=J%2013%20%C3%A5r"

Look to the openAPI specification for the details.

Develop and run locally

Requirements

% curl -LsSf https://astral.sh/uv/install.sh | sh

Install software

% git clone https://github.com/langrenn-sprint/event-service.git
% cd event-service
% uv sync

Environment variables

An example .env file for local development:

JWT_SECRET=test_jwt_secret_key_for_development_do_not_use_in_production_12345
JWT_EXP_DELTA_SECONDS=3600
ADMIN_USERNAME=admin
ADMIN_PASSWORD=password
USERS_HOST_SERVER=localhost
USERS_HOST_PORT=8086
DB_HOST=localhost
DB_NAME=events_test
DB_USER=event-service
DB_PASSWORD=password
LOGGING_LEVEL=DEBUG

Running the API locally

Start the server locally:

% uv run --env-file .env fastapi dev

Running the API in a asgi-server (uvicorn)

% uv run --env-file .env uvicorn app:api --host 0.0.0.0 --port 8000 --workers 1 --log-config=logging.yaml

Running the wsgi-server in Docker

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:8000 -d ghcr.io/langrenn-sprint/event-service:latest

The easier way would be with docker-compose:

docker-compose up --build

Running tests

We use pytest for contract testing.

To run linters, checkers and tests:

% uv run poe release

To run specific test:

% uv run poe integration_test --no-cov -- test_create_event_adapter_fails

To run tests with logging, do:

% uv run poe integration_test  --log-cli-level=DEBUG

About

Backend service to adminster events, will generate racelists etc

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors