crabfit/api
2025-05-08 08:54:30 -04:00
..
adaptors Password files must be trimmed of newlines 2025-05-08 08:54:30 -04:00
common Change how cleanup trait fn works using a date cutoff 2023-05-16 01:37:01 +10:00
src Password files must be trimmed of newlines 2025-05-08 08:54:30 -04:00
.dockerignore Set up dockerfile, and handle SIGINT signals 2023-05-16 15:36:53 +10:00
.gitignore Include documentation for API and subcrates 2023-05-15 23:51:12 +10:00
Cargo.lock Add ability to read database password from a file 2025-05-07 10:10:04 -04:00
Cargo.toml Update API version 2023-05-16 02:23:57 +10:00
Dockerfile Add ability to read secrets from files 2025-05-06 09:24:35 -04:00
fly.toml Reconfigure to use Fly.io, update workflow 2023-05-16 20:22:15 +10:00
README.md Add docs for FRONTEND_URL env var 2023-05-16 02:42:01 +10:00

Crab Fit API

This is the API for Crab Fit, written in Rust. It uses the axum framework to run a HTTP server, and supports multiple storage adaptors.

API docs

OpenAPI compatible API docs are generated using utoipa. You can visit them at https://api.crab.fit/docs.

Storage adaptors

Adaptor Works with
memory-adaptor Stores data in memory
sql-adaptor Postgres, MySQL, SQLite
datastore-adaptor Google Datastore

To choose an adaptor, specify it in the features when compiling, e.g. cargo run --features sql-adaptor.

Some adaptors require environment variables to be set. You can specify them in a .env file and they'll be loaded in using dotenvy. See a specific adaptor's readme for more information.

Note

memory-adaptor is the default if no features are specified. Ensure you specify a different adaptor when deploying.

Adding an adaptor

See adding an adaptor in the adaptors readme.

Environment

CORS

In release mode, a FRONTEND_URL environment variable is required to correctly restrict cross-origin requests to the frontend.

Cleanup task

By default, anyone can run the cleanup task at /tasks/cleanup. This is usually not an issue, as it's based on when the events were last visited, and not when it's run, but if you'd prefer to restrict runs of the cleanup task (as it can be intensive), set a CRON_KEY environment variable in .env. This will require sending an X-Cron-Key header to the route with a value that matches CRON_KEY, or the route will return a 401 Unauthorized error.