Todo example — backend reference

cargo run -p example-todo — full Resuma showcase plus production backend patterns in Rust.

Files

FileRole
src/main.rsUI, #[server] controllers, island
src/todo_store.rsService layer + DTO validation
src/security.rsGuards, interceptors, SecurityConfig

Try it

  1. Run the app, open DevTools → Network
  2. Default user: guest — sees only guest tasks
  3. Click alice — admin, sees all tasks
  4. As guest, try toggling alice's task → 403 Forbidden
  5. Check terminal logs: request id + user + IP per action
cargo run -p example-todo

Patterns implemented

  • Session guardattach_session() in action middleware
  • DTO validationAddTodoInput, RenameTodoInput
  • Domain servicetodo_store::add() etc.
  • Server action — thin #[server] → delegates to store
  • Client RPC__resuma.action() with CSRF
  • Loader refreshlist_todos on island mount via use_visible_task
  • Audit log — request id + structured action log
  • Error mappingResult<T> → HTTP status

Env vars

VariablePurpose
RESUMA_ENV=productionSanitized client error messages
RESUMA_TRUST_PROXY=1Real client IP behind Fly/nginx
RESUMA_TODO_ADMINSAdmin users (default: alice)
RESUMA_TODO_API_KEYOptional shared secret for actions

See also: Backend patterns · Authorization: RLS guide.