Guides
Getting Started
Create your first Lithair application in minutes:
cargo install lithair-cli
lithair new my-app
cd my-app && cargo run
Your server is now running at http://127.0.0.1:3007.
Adding a Data Model
Define a model with the declarative macro:
use lithair_core::DeclarativeModel;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize, DeclarativeModel)]
struct Article {
#[http(expose)]
id: String,
#[db(indexed)]
#[http(expose, validate = "non_empty")]
title: String,
#[http(expose)]
content: String,
#[http(expose)]
#[lifecycle(audited, versioned)]
status: String,
}
Register it with .with_model::<Article>("./data/articles", "/api/articles") to generate CRUD endpoints, validation, and persistence automatically.
Enabling Authentication
Configure RBAC with .with_rbac_config(...) and a session store via .with_sessions(...) to enable role-based, session-backed authentication.