reinhardt_admin/server.rs
1//! Server Functions for Reinhardt admin panel
2//!
3//! This crate provides Server Functions that handle admin panel operations,
4//! replacing the traditional REST API handlers with reinhardt-pages Server Functions.
5//!
6//! # Architecture
7//!
8//! Each module contains Server Functions for specific admin operations:
9//! - `dashboard` - Dashboard data retrieval
10//! - `list` - List view operations
11//! - `detail` - Detail view operations
12//! - `create` - Create operations
13//! - `update` - Update operations
14//! - `delete` - Delete operations (including bulk delete)
15//! - `export` - Export operations
16//! - `import` - Import operations
17//!
18//! # Server Functions
19//!
20//! Server Functions use `#[server_fn]` macro and support:
21//! - Automatic DI injection via `#[inject]` parameter
22//! - JSON codec for complex request/response types
23//! - Automatic error conversion to `ServerFnError`
24//! - CSRF protection (handled automatically by reinhardt-pages)
25//!
26//! # Example
27//!
28//! ```ignore
29//! use reinhardt_admin::server::dashboard::get_dashboard;
30//!
31//! // In your app
32//! let dashboard_data = get_dashboard().await?;
33//! ```
34
35// The `#[server_fn]` proc macro generates internal modules that cannot have doc comments.
36// Allow missing docs for all server function submodules.
37#[cfg(server)]
38pub(crate) mod admin_auth;
39#[allow(missing_docs)]
40pub mod create;
41#[allow(missing_docs)]
42pub mod dashboard;
43#[allow(missing_docs)]
44pub mod delete;
45#[allow(missing_docs)]
46pub mod detail;
47/// Error handling utilities for server functions.
48#[cfg(server)]
49pub mod error;
50#[allow(missing_docs)]
51pub mod export;
52#[allow(missing_docs)]
53pub mod fields;
54#[allow(missing_docs)]
55pub mod import;
56/// Request size and rate limits for server functions.
57pub mod limits;
58#[allow(missing_docs)]
59pub mod list;
60#[allow(missing_docs)]
61pub mod login;
62#[allow(missing_docs)]
63pub mod logout;
64mod serde_helpers;
65#[allow(missing_docs)]
66pub mod update;
67#[cfg(server)]
68pub(crate) mod user;
69
70pub mod audit;
71/// Cookie-based JWT authentication middleware for admin panel.
72#[cfg(not(target_arch = "wasm32"))]
73pub mod cookie_auth;
74/// Origin guard middleware restricting admin server functions to SPA-only access.
75#[cfg(not(target_arch = "wasm32"))]
76pub mod origin_guard;
77pub mod security;
78
79// Server-side only modules
80#[cfg(server)]
81pub mod type_inference;
82#[cfg(server)]
83pub mod validation;
84
85// Re-exports
86#[cfg(server)]
87pub use admin_auth::AdminAuthenticatedUser;
88pub use create::*;
89pub use dashboard::*;
90pub use delete::*;
91pub use detail::*;
92pub use export::*;
93pub use fields::*;
94pub use import::*;
95pub use list::*;
96pub use update::*;
97#[cfg(server)]
98pub use user::AdminDefaultUser;