This project encapsulates the backend infrastructure of CS2KZ. It is developed in tandem with the plugin and currently WIP.
If you want to run the API locally, see Local Setup. The recommended tooling for development is listed under Tooling. The project structure is documented in ARCHITECTURE.md.
Questions and feedback are appreciated! Feel free to open an issue or join our Discord.
Important
It is expected you have the required tools described in tooling installed on your system.
The API uses a configuration file called cs2kz-api.toml
.
An example configuration file is provided with all the default values filled in,
copy and modify it as you see fit. .example.env
and .docker.example.env
should be copied to .env
and .docker.env
respectively. Again, change the
default values as you see fit.
The API requires a MariaDB instance in order to run. It is recommended that you
run one using Docker using the compose.yaml
file provided by this
repository.
Install docker and run the following command:
docker compose up -d database
To compile the API itself, you can use cargo
:
# also specify `--release` to enable optimizations
cargo build --locked --package=cs2kz-api --bin=cs2kz-api
# compile & run in one step
cargo run --locked --package=cs2kz-api --bin=cs2kz-api
To compile and run with Docker instead:
docker compose up --build api
The nix flake in the repository root also outputs the API binary as its default package.
Debugging with tokio-console
The API supports sending trace data to tokio-console
so you can inspect the
runtime in real time. In order to use it, set tracing.console.enable
to true
in your configuration file.
- rustup to install the Rust toolchain
- Docker for running the database and (optionally) the API itself
- sqlx-cli for managing database migrations
- DepotDownloader (optional) for downloading workshop maps; required for
PUT /maps
andPATCH /maps/{map_id}
- just (optional) as a command runner
- nix (optional) if you know you know
See CONTRIBUTING.md.