apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: api-axum
  title: Rust — Axum (lightweight)
  description: |
    Minimal Rust HTTP API built on Axum (Tokio team, Hyper + Tower
    stack, typed extractors). Pick this for compact services and
    APIs where Tokio ecosystem integration and Tower-style
    middleware matter.
  tags:
    - rust
    - lightweight-api
    - axum
  links:
    - url: https://docs.rs/axum/
      title: Axum
    - url: https://tokio.rs/
      title: Tokio
    - url: https://doc.rust-lang.org/cargo/
      title: Cargo
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: axum
        frontend:
          title: Frontend
          type: string
          const: api-only
        database:
          title: Database
          type: string
          enum:
            - postgres
            - sqlite
            - mysql
            - none
          enumNames:
            - 'Postgres — default'
            - 'SQLite'
            - 'MySQL'
            - 'None — stateless service'
        persistence:
          title: Persistence Library
          type: string
          default: sqlx
          enum:
            - sqlx
            - sea-orm
            - none
          enumNames:
            - 'sqlx — query-first, compile-time-checked SQL'
            - 'SeaORM — async-first ORM with relations'
            - 'None — direct driver'
        background_jobs:
          title: Background Jobs
          type: string
          default: none
          enum:
            - none
            - apalis
          enumNames:
            - 'None'
            - 'apalis — pluggable backends (Redis, Postgres, SQS)'
        auth:
          title: Authentication
          type: string
          default: none
          enum:
            - none
            - jsonwebtoken
          enumNames:
            - 'None'
            - 'jsonwebtoken — JWT middleware'
        observability:
          title: Observability
          type: string
          default: tracing
          enum:
            - tracing
            - opentelemetry
            - none
          enumNames:
            - 'tracing — structured logs/spans'
            - 'OpenTelemetry — tracing + otel SDK'
            - 'None'
  tooling:
    package_manager: cargo
    language_flavor: rust
    test_runner: cargo-test
    lint_format: rustfmt-clippy
    runtime_cli: cargo
  smoke_test: |
    GET /health returns 200. One Rust test uses tower::ServiceExt
    `oneshot` to invoke the router and asserts the response.
  switch_when: |
    Need richer service stack (sqlx + tower middleware + OpenTelemetry
    by default + graceful shutdown) → service-axum. Different
    runtime/perf profile or actor model → Actix Web (future
    sibling). Full-stack SSR → Leptos (future sibling).
