4 releases (2 breaking)

new 0.2.1 Jan 21, 2025
0.2.0 Jan 20, 2025
0.1.0 Dec 25, 2024
0.0.1 Sep 29, 2024

#1192 in HTTP server

Download history 160/week @ 2024-09-25 37/week @ 2024-10-02 8/week @ 2024-10-09 2/week @ 2024-12-04 4/week @ 2024-12-11 199/week @ 2024-12-25 4/week @ 2025-01-08

203 downloads per month

Apache-2.0

140KB
4K SLoC

Stefn

Fast and cool meta framework.

Simple and easy.

mod dashboard;
mod website;

use axum::{middleware::from_fn_with_state, Router};
use hyper::{
    header::{AUTHORIZATION, CONTENT_TYPE},
    Method,
};

use stefn::{
    auth::{login_required_middleware, sessions_middleware},
    service::Service,
    state::WebsiteState,
};

use tower_http::{
    cors::{Any, CorsLayer},
    services::ServeDir,
};

pub fn create_service() -> Service {
    Service::website("WEB_", routes)
}

fn routes(state: WebsiteState) -> Router<WebsiteState> {
    Router::new()
        .merge(dashboard::routes(state.clone()))
        .layer(from_fn_with_state(state.clone(), login_required_middleware))
        .merge(website::routes(state.clone()))
        .layer(from_fn_with_state(state.clone(), sessions_middleware))
        .nest_service("/dist", ServeDir::new("dist"))
        .layer(
            CorsLayer::new()
                .allow_methods([Method::GET, Method::POST, Method::PUT])
                .allow_headers([CONTENT_TYPE, AUTHORIZATION])
                .allow_origin(Any),
        )
        .with_state(state)
}
use my_app::create_service;
use stefn::orquestrator::ServicesOrquestrator;

fn main() {
    ServicesOrquestrator::default()
        .load_environment_variables()
        .set_config_from_env()
        .enable_migrations()
        .add_service(create_service())
        .init_dev_tracing()
        .run();
}

Dependencies

~69–105MB
~2M SLoC