1pub mod error;
8pub mod types;
9pub mod handler;
10pub mod executor;
11pub mod runtime;
12pub mod integration;
13
14#[cfg(feature = "wasm")]
19pub mod wasm;
20
21#[cfg(feature = "websocket")]
22pub mod websocket;
23
24#[cfg(feature = "cli")]
25pub mod cli;
26
27#[cfg(feature = "web")]
28pub mod web;
29
30#[cfg(feature = "templates")]
31pub mod templates;
32
33#[cfg(feature = "database")]
34pub mod database;
35
36#[cfg(feature = "auth")]
37pub mod auth;
38
39#[cfg(feature = "dev_server")]
40pub mod dev_server;
41
42pub use error::{HandlerError, Result};
43pub use types::*;
44pub use handler::UnifiedHandler;
45pub use executor::HandlerExecutor;
46
47pub use kotoba_storage::KeyValueStore;
49pub use std::sync::Arc;
50
51#[cfg(feature = "wasm")]
60pub fn init_wasm_handler() -> Result<wasm::WasmHandler> {
61 wasm::WasmHandler::new()
62}
63
64#[cfg(feature = "cli")]
66pub async fn execute_cli_handler(file: &str, args: Vec<String>) -> Result<String> {
67 cli::execute_handler(file, args).await
68}
69
70pub async fn execute_simple_handler_with_storage<T: KeyValueStore + 'static>(
73 storage: Arc<T>,
74 content: &str,
75 context: HandlerContext,
76) -> Result<String> {
77 let handler = UnifiedHandler::new(storage);
78 handler.execute(content, context).await
79}
80
81#[cfg(feature = "web")]
91pub async fn run_web_app(addr: &str, config: web::WebConfig) -> Result<()> {
92 web::run_web_app(addr, config).await
93}
94
95#[cfg(feature = "dev_server")]
97pub async fn run_dev_server(addr: &str, config: dev_server::DevServerConfig) -> Result<()> {
98 dev_server::run_dev_server(addr, config).await
99}
100
101#[cfg(feature = "database")]
103pub async fn init_database(url: &str) -> Result<database::DatabaseConnection> {
104 database::init_connection(url).await
105}
106
107#[cfg(feature = "auth")]
109pub fn create_auth_middleware(config: auth::AuthConfig) -> auth::AuthMiddleware {
110 auth::AuthMiddleware::new(config)
111}
112
113#[cfg(feature = "templates")]
115pub fn init_template_engine(template_dir: &str) -> Result<templates::TemplateEngine> {
116 templates::TemplateEngine::new(template_dir)
117}
118