ryuk-cli 0.1.1

The `ryuk` command: scaffold a Ryuk app (axum, SeaORM, Inertia/Svelte), generate controllers, models, jobs and mails, run migrations and the dev server.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! JSON handlers for the api group (`src/api.rs`). `ryuk make:api Name` adds a module here.
use ryuk::api::{ApiError, Principal};

pub mod devices;
pub mod me;
pub mod posts;
pub mod sessions;

/// The user a key acts for; system keys (no owner) get 403 on user-scoped resources.
pub fn owner(p: &Principal) -> Result<i64, ApiError> {
    p.user_id.ok_or(ApiError {
        status: axum::http::StatusCode::FORBIDDEN,
        code: "forbidden",
        message: "This credential has no user; it cannot access user resources".into(),
    })
}