reafctor: all code without stream

This commit is contained in:
2026-06-02 18:30:39 +02:00
parent 974be437af
commit 28352d8bdb
90 changed files with 3581 additions and 2434 deletions
+25
View File
@@ -0,0 +1,25 @@
use crate::api::errors::ApiError;
use crate::api::state::SharedState;
use crate::api::types::{CreateApiKeyRequest, CreateApiKeyResponse};
use crate::core::auth::Auth;
use axum::{
Json,
extract::{Extension, State},
};
pub async fn create_api_key(
State(state): State<SharedState>,
Extension(claims): Extension<Auth>,
Json(body): Json<CreateApiKeyRequest>,
) -> Result<Json<CreateApiKeyResponse>, ApiError> {
let payload = crate::core::auth::api_key::CreateApiKeyRequest {
user_id: claims.user_id(),
name: body.name,
roles: body.scopes.into_iter().map(Into::into).collect(),
};
let key = state.auth_service.create_api_key(payload).await?;
Ok(Json(CreateApiKeyResponse { api_key: key }))
}