Skip to content

Latest commit

 

History

History
79 lines (56 loc) · 1.48 KB

README.md

File metadata and controls

79 lines (56 loc) · 1.48 KB

Reconductor API backend

This is an API backend. It provides HTTP API endpoints to be called from a frontend app and/or any other client apps

Installation

Install Rust

Install dependencies

cargo install
cargo install sqlx-cli

Database

This project uses sqlx. SQLx requires having a live database for project to compile. This may feel inconvenient at first but it's actually very useful in development because it allows You to identify issues with SQL queries early. To use this feature DATABASE_URL env variable must be set.

# Run the database and apply the migrations
podman compose -f docker-compose.yml --profile=infra up -d
export DATABASE_URL=some_url

Running locally

cargo run

Running tests

cargo test

Production build

Production builds run independently from database therefore SQLx queries must be prepared upfront. Run this command every time You make a change to the database:

cargo sqlx prepare

This will create (update) .sqlx directory with database metadata. .sqlx directory must me checked in version control

Now You can build for production:

cargo build --release

Optionally You can make build work offline by setting SQLX_OFFLINE environment variable but it's not recommended for local development

export SQLX_OFFLINE=true
unset DATABASE_URL