Skip to content

Latest commit

 

History

History
83 lines (59 loc) · 2.75 KB

README.md

File metadata and controls

83 lines (59 loc) · 2.75 KB

Dependency Status

CS2KZ API

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.

Local Setup

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.

Tooling

  1. rustup to install the Rust toolchain
  2. Docker for running the database and (optionally) the API itself
  3. sqlx-cli for managing database migrations
  4. DepotDownloader (optional) for downloading workshop maps; required for PUT /maps and PATCH /maps/{map_id}
  5. just (optional) as a command runner
  6. nix (optional) if you know you know

Contributing

See CONTRIBUTING.md.