Environment Variables

Application, Server & Database

Application

VariableDefaultDescription
DEBUGfalseGlobal dev/prod switch — read once at startup via LazyLock. Enables: debug log level, detailed error pages, admin template hot reload. In production (false): warn level, generic errors.
BASE_DIR.Application root directory
TZUTCIANA timezone for the application (e.g. Europe/Paris, America/New_York). Accessible via config.timezone — parse it with chrono-tz in your project.
LANGsystem localeCLI language (fr, en, de, es, it, pt, ja, zh, ru). Priority: .env > system locale (LC_ALL, LC_MESSAGES) > en

Server

VariableDefaultDescription
IP_SERVER127.0.0.1Listening IP address
PORT3000Listening port
SECRET_KEYdefault_secret_keySecret key (CSRF, signatures). In production (DEBUG=false), boot fails if it's empty, equal to the default, or under 32 characters

Database

Connection

VariableDefaultDescription
DATABASE_URLFull connection URL (takes priority over all component variables)
DB_ENGINEsqliteEngine: postgres, mysql, mariadb, sqlite
DB_USERUsername (required except for SQLite)
DB_PASSWORDPassword (required except for SQLite)
DB_HOSTlocalhostHost
DB_PORT5432 / 3306Port (default depends on engine)
DB_NAMElocal_base.sqlite (SQLite only)Database name — required for postgres/mysql/mariadb, startup fails if absent

Connection pool

VariableDefaultDescription
DB_MAX_CONNECTIONS100Maximum pool size
DB_MIN_CONNECTIONS20Minimum pool size

Timeouts

VariableDefaultUnitDescription
DB_CONNECT_TIMEOUT2secondsConnection establishment timeout
DB_ACQUIRE_TIMEOUT500millisecondsPool acquire timeout
DB_IDLE_TIMEOUT300secondsIdle connection lifetime
DB_MAX_LIFETIME3600secondsMaximum connection lifetime

SQL Logging

VariableDefaultDescription
DB_LOGGINGfalseEnable SQL query logging (true, 1, yes)

Secondary connections — `with_custom_db`

To attach an additional database connection (Redis pool, secondary PostgreSQL, MongoDB client, etc.), use .with_custom_db() on the builder. The value is stored in a HashMap<TypeId, Arc<dyn Any>> internal to RuniqueEnginenot injected as an Axum Extension. Access it in handlers via engine.custom_db::<T>() (or its alias engine.extension::<T>()), which returns Option<Arc<T>>.

// main.rs
let redis = redis::Client::open("redis://127.0.0.1/")?;
let db = DatabaseConfig::from_env()?.build().connect().await?;

RuniqueAppBuilder::new(config)
    .with_database(db)
    .with_custom_db(redis)   // T: Any + Send + Sync + 'static
    .routes(url::urlpatterns())
    .build().await?
    .run().await
// handler
use redis::Client;

pub async fn my_handler(mut req: Request) -> AppResult<Response> {
    let redis = req.engine.custom_db::<Client>().expect("redis not configured");
    let mut conn = redis.get_async_connection().await?;
    // ...
}

Any type implementing Any + Send + Sync + 'static is accepted. Multiple secondary connections of different types can be registered with repeated .with_custom_db() calls.