Skip to main content

modo/
lib.rs

1//! # modo
2//!
3//! A Rust web framework for small monolithic apps.
4//!
5//! Single crate, zero proc macros. Handlers are plain `async fn`, routes use
6//! axum's [`Router`](axum::Router) directly, services are wired explicitly in
7//! `main()`, and database queries use raw libsql.
8//!
9//! ## Quick start
10//!
11//! ```toml
12//! [dependencies]
13//! modo = "0.6"
14//! ```
15//!
16//! The `db` feature is enabled by default. Enable additional modules via
17//! feature flags: `session`, `job`, `auth`, `templates`,
18//! `sse`, `email`, `storage`, `webhooks`, `dns`, `geolocation`, `qrcode`,
19//! `sentry`, `apikey`, `text-embedding`, `tier`.
20//!
21//! Or enable everything:
22//!
23//! ```toml
24//! [dependencies]
25//! modo = { version = "0.6", features = ["full"] }
26//! ```
27
28#[cfg(feature = "db")]
29pub mod audit;
30pub mod cache;
31pub mod config;
32pub mod cookie;
33#[cfg(feature = "db")]
34pub mod db;
35pub mod encoding;
36pub mod error;
37pub mod extractor;
38pub mod flash;
39pub mod health;
40pub mod id;
41pub mod ip;
42pub mod middleware;
43pub mod runtime;
44pub mod sanitize;
45pub mod server;
46pub mod service;
47#[cfg(feature = "session")]
48pub mod session;
49pub mod tracing;
50pub mod validate;
51
52pub mod cron;
53#[cfg(feature = "job")]
54pub mod job;
55pub mod rbac;
56pub mod tenant;
57
58#[cfg(feature = "text-embedding")]
59pub mod embed;
60
61#[cfg(feature = "auth")]
62pub mod auth;
63
64#[cfg(feature = "email")]
65pub mod email;
66
67#[cfg(feature = "templates")]
68pub mod template;
69
70#[cfg(feature = "sse")]
71pub mod sse;
72
73#[cfg(feature = "storage")]
74pub mod storage;
75
76#[cfg(feature = "webhooks")]
77pub mod webhook;
78
79#[cfg(feature = "dns")]
80pub mod dns;
81
82#[cfg(feature = "apikey")]
83pub mod apikey;
84
85#[cfg(feature = "tier")]
86pub mod tier;
87
88#[cfg(feature = "geolocation")]
89pub mod geolocation;
90
91#[cfg(feature = "qrcode")]
92pub mod qrcode;
93
94#[cfg(feature = "test-helpers")]
95pub mod testing;
96
97pub use config::Config;
98pub use error::{Error, Result};
99
100#[cfg(feature = "db")]
101pub use audit::{AuditEntry, AuditLog, AuditLogBackend, AuditRecord, AuditRepo};
102#[cfg(feature = "text-embedding")]
103pub use embed::{
104    EmbeddingBackend, EmbeddingProvider, GeminiConfig, GeminiEmbedding, MistralConfig,
105    MistralEmbedding, OpenAIConfig, OpenAIEmbedding, VoyageConfig, VoyageEmbedding, from_f32_blob,
106    to_f32_blob,
107};
108pub use extractor::ClientInfo;
109pub use extractor::Service;
110pub use flash::{Flash, FlashEntry, FlashLayer};
111pub use health::{HealthCheck, HealthChecks};
112pub use ip::{ClientIp, ClientIpLayer};
113pub use rbac::{Role, RoleExtractor};
114pub use sanitize::Sanitize;
115#[cfg(feature = "session")]
116pub use session::{Session, SessionConfig, SessionData, SessionLayer, SessionToken};
117pub use tenant::{
118    HasTenantId, Tenant, TenantId, TenantLayer, TenantResolver, TenantStrategy,
119    middleware as tenant_middleware,
120};
121pub use validate::{Validate, ValidationError, Validator};
122
123#[cfg(all(feature = "db", feature = "dns"))]
124pub use tenant::domain::{ClaimStatus, DomainClaim, DomainService, TenantMatch};
125
126#[cfg(feature = "auth")]
127pub use auth::oauth::{
128    AuthorizationRequest, CallbackParams, GitHub, Google, OAuthConfig, OAuthProvider,
129    OAuthProviderConfig, OAuthState, UserProfile,
130};
131
132#[cfg(feature = "auth")]
133pub use auth::jwt::{
134    Bearer, Claims, HmacSigner, JwtConfig, JwtDecoder, JwtEncoder, JwtError, JwtLayer, Revocation,
135    TokenSigner, TokenSource, TokenVerifier, ValidationConfig,
136};
137
138#[cfg(feature = "templates")]
139pub use template::{
140    Engine, EngineBuilder, HxRequest, Renderer, TemplateConfig, TemplateContext,
141    TemplateContextLayer,
142};
143
144#[cfg(feature = "storage")]
145pub use storage::{Acl, BucketConfig, Buckets, PutFromUrlInput, PutInput, PutOptions, Storage};
146
147#[cfg(feature = "webhooks")]
148pub use webhook::{SignedHeaders, WebhookResponse, WebhookSecret, WebhookSender};
149
150#[cfg(feature = "dns")]
151pub use dns::{DnsConfig, DnsError, DomainStatus, DomainVerifier, generate_verification_token};
152
153#[cfg(feature = "apikey")]
154pub use apikey::{
155    ApiKeyBackend, ApiKeyConfig, ApiKeyCreated, ApiKeyLayer, ApiKeyMeta, ApiKeyRecord, ApiKeyStore,
156    CreateKeyRequest, require_scope,
157};
158
159#[cfg(feature = "tier")]
160pub use tier::{
161    FeatureAccess, TierBackend, TierInfo, TierLayer, TierResolver, require_feature, require_limit,
162};
163
164#[cfg(feature = "geolocation")]
165pub use geolocation::{GeoLayer, GeoLocator, GeolocationConfig, Location};
166
167#[cfg(feature = "qrcode")]
168pub use qrcode::{Color, Ecl, FinderShape, ModuleShape, QrCode, QrError, QrStyle};
169
170#[cfg(all(feature = "qrcode", feature = "templates"))]
171pub use qrcode::qr_svg_function;
172
173// Re-exports for user convenience
174pub use axum;
175pub use serde;
176pub use serde_json;
177pub use tokio;