Check our API Docs for more information.
-
Install Rust via rustup:
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | shThe project pins its Rust version in
rust-toolchain.toml— rustup will automatically install and use the correct version. -
Create the data directory for the SQLite databases:
mkdir -p ~/.local/share/btcmap -
Install sqlite3_rsync (needed to fetch the production database):
# macOS brew install sqlite-rsync -
Configure SSH access to the production server (needed for fetching data). Add to
~/.ssh/config:Host btcmap-api User root Hostname <server-ip>
cargo build
cargo test
The API needs a database to serve data. Fetch a copy of the production database:
./devtools fetch-main-db
This uses sqlite3_rsync to sync the main database from the production server.
cargo run
The server binds to http://127.0.0.1:8000. Test it with:
curl http://localhost:8000/v2/areas
The devtools script provides helper commands for development:
| Command | Description |
|---|---|
main-db [query] |
Open the main database in sqlite3 (or run a query) |
image-db [query] |
Open the image database in sqlite3 |
log-db [query] |
Open the log database in sqlite3 |
fetch-db |
Fetch all databases from production |
fetch-main-db |
Fetch only the main database |
fetch-image-db |
Fetch only the image database |
fetch-log-db |
Fetch only the log database |
deploy |
Run tests, build release, deploy to production |
gen-main-schema |
Generate schema.sql from migrations |
install-completions |
Install bash tab completions for devtools |