mirror of
https://github.com/Such-Software/smirk-backend-core.git
synced 2026-10-18 16:01:33 +02:00
chore: initial foundation — server skeleton, autodocs, CI
- minimal Axum server exposing GET /health - OpenAPI contract generated from handlers (gen_openapi -> openapi.json), drift-gated in CI so the spec can never silently diverge from the code - CI: secret-scan + gitleaks, openapi drift gate, fmt/clippy/build/test/doc-test, cargo-deny - Cargo.lock tracked for reproducible builds; publish=false; pinned toolchain - README, SECURITY.md, deny.toml, .env.example
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
//! Health / liveness endpoint.
|
||||
|
||||
use axum::Json;
|
||||
use serde::Serialize;
|
||||
|
||||
/// Liveness response.
|
||||
#[derive(Serialize, utoipa::ToSchema)]
|
||||
pub struct HealthResponse {
|
||||
/// Always `"ok"` when the service is reachable.
|
||||
pub status: String,
|
||||
}
|
||||
|
||||
/// Liveness probe.
|
||||
///
|
||||
/// Returns `200` with `{ "status": "ok" }` whenever the server is up. Used by
|
||||
/// load balancers and uptime checks; requires no authentication.
|
||||
#[utoipa::path(
|
||||
get,
|
||||
path = "/health",
|
||||
responses((status = 200, description = "Service is up", body = HealthResponse)),
|
||||
tag = "system"
|
||||
)]
|
||||
pub async fn health() -> Json<HealthResponse> {
|
||||
Json(HealthResponse {
|
||||
status: "ok".to_string(),
|
||||
})
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
//! HTTP API layer: handlers and the OpenAPI assembly.
|
||||
|
||||
pub mod health;
|
||||
pub mod openapi;
|
||||
@@ -0,0 +1,21 @@
|
||||
//! OpenAPI specification assembly.
|
||||
//!
|
||||
//! `ApiDoc` aggregates the annotated handlers into the spec that is the single
|
||||
//! source of truth for the API contract and the wallet's generated TypeScript
|
||||
//! client. Add a path here once its handler carries `#[utoipa::path(...)]` and
|
||||
//! its request/response types derive `utoipa::ToSchema`.
|
||||
|
||||
use utoipa::OpenApi;
|
||||
|
||||
#[derive(OpenApi)]
|
||||
#[openapi(
|
||||
info(
|
||||
title = "smirk-backend-core",
|
||||
version = "0.3.0",
|
||||
description = "Open, self-hostable backend for the Smirk non-custodial multi-chain wallet."
|
||||
),
|
||||
paths(crate::api::health::health),
|
||||
components(schemas(crate::api::health::HealthResponse)),
|
||||
tags((name = "system", description = "Service health and metadata."))
|
||||
)]
|
||||
pub struct ApiDoc;
|
||||
Reference in New Issue
Block a user