Skip to main content

capy_framework/
lib.rs

1//! An opinionated full-stack Rust web framework with strong conventions and sensible defaults.
2//!
3//! Capy integrates routing, validation, configuration, and database tooling with
4//! a predictable application structure.
5//!
6//! Depend on this package as `capy = { package = "capy-framework", version = "0.6.0" }`.
7//! The prelude contains the common API; named re-exports retain native escape hatches.
8
9mod app;
10#[cfg(feature = "mail")]
11mod mail_commands;
12#[cfg(feature = "mail")]
13pub use capy_mail as mail;
14#[cfg(feature = "mail")]
15pub use capy_mail::notifications;
16#[cfg(feature = "jobs")]
17mod job_commands;
18#[cfg(feature = "jobs")]
19pub use capy_jobs as jobs;
20mod diagnostics;
21mod frontend;
22mod http_policy;
23mod readiness;
24
25pub use diagnostics::{RequestObservation, RequestObserver};
26pub use readiness::{ready, ReadinessResponse};
27
28pub use app::App;
29#[cfg(feature = "auth")]
30pub use capy_auth as auth;
31pub use capy_core::{
32    ApiErrorResponse, ApiSettings, AppConfig, AppContext, AppError, AppSettings, AuthSettings,
33    AuthThrottleLimit, AuthThrottleSettings, ClientIpResolver, ClientIpSettings, ClientIpStrategy,
34    Context, DatabaseSettings, Event, EventBus, EventContext, EventError, EventFuture,
35    EventRejection, EventResult, Events, HashConcurrency, HttpSettings, JobsSettings, MailSettings,
36    PasswordSettings, Result, SameSite, ServerSettings, SmtpSettings, ValidationErrors,
37};
38pub use capy_db as db;
39pub use capy_db::{SeedContext, SeedFuture, Seeds};
40pub use capy_http::{
41    health, schema, ApiDocument, ApiRouteInfo, ApiSchema, Created, HealthResponse, Json, NoContent,
42    Page, PageMeta, Paginated, Pagination, PaginationMeta, Path, Query, RouteInfo, Routes,
43};
44pub use capy_validation::Validated;
45
46pub use axum;
47pub use chrono;
48pub use sea_orm;
49pub use sea_orm_migration as migration;
50pub use serde;
51pub use serde_json;
52pub use tokio;
53pub use tower;
54pub use tower_http;
55pub use tracing;
56pub use uuid;
57pub use validator;
58
59#[cfg(feature = "testing")]
60pub use capy_testing as testing;
61
62/// The small set of types most API handlers need.
63pub mod prelude {
64    pub use crate::{
65        ApiSchema, App, AppConfig, AppContext, AppError, Context, Created, Event, EventBus,
66        EventError, EventRejection, EventResult, Json, NoContent, Page, Paginated, Pagination,
67        Path, Query, Result, Routes, Validated,
68    };
69    #[cfg(feature = "jobs")]
70    pub use capy_jobs::{JobDispatch, TransactionalJobDispatch};
71    #[cfg(feature = "mail")]
72    pub use capy_mail::{MailContext, Mailable};
73    pub use sea_orm::DatabaseConnection;
74    pub use serde::{Deserialize, Serialize};
75    pub use serde_json::{json, Value};
76    pub use validator::Validate;
77}
78
79mod dev_logging;