apiVersion: scaffolder.backstage.io/v1beta3
kind: Template
metadata:
  name: api-ring-reitit
  title: Clojure — Ring + Reitit (lightweight)
  description: |
    Idiomatic Clojure HTTP service: Ring (request/response abstraction)
    with Reitit (data-driven router) on Jetty. deps.edn project
    layout, kaocha for tests, clj-kondo for linting. Pick this for
    minimal services where lifecycle and observability conventions
    aren't worth the ceremony.
  tags:
    - clojure
    - lightweight-api
    - ring
    - reitit
  links:
    - url: https://github.com/ring-clojure/ring/wiki
      title: Ring
    - url: https://cljdoc.org/d/metosin/reitit/
      title: Reitit
    - url: https://clojure.org/guides/deps_and_cli
      title: deps.edn / Clojure CLI
    - url: https://github.com/lambdaisland/kaocha
      title: Kaocha
spec:
  owner: abp
  type: service
  parameters:
    - title: Stack Configuration
      required:
        - database
      properties:
        backend:
          title: Backend
          type: string
          const: ring-reitit
        frontend:
          title: Frontend
          type: string
          const: api-only
        server:
          title: HTTP Server
          type: string
          default: jetty
          enum:
            - jetty
            - http-kit
            - aleph
          enumNames:
            - 'Jetty — ring-jetty-adapter, simplest'
            - 'HTTP Kit — async, low-memory'
            - 'Aleph — Netty-backed, async + websockets'
        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: next-jdbc
          enum:
            - next-jdbc
            - next-jdbc-honeysql
            - none
          enumNames:
            - 'next.jdbc — modern Clojure JDBC'
            - 'next.jdbc + HoneySQL — query DSL'
            - 'None — direct driver'
        background_jobs:
          title: Background Jobs
          type: string
          default: none
          enum:
            - none
            - core-async
          enumNames:
            - 'None'
            - 'core.async — in-process channels (no durability)'
        auth:
          title: Authentication
          type: string
          default: none
          enum:
            - none
            - buddy-auth
          enumNames:
            - 'None'
            - 'buddy-auth — JWT / session middleware'
        observability:
          title: Observability
          type: string
          default: tools-logging
          enum:
            - tools-logging
            - opentelemetry
            - none
          enumNames:
            - 'clojure.tools.logging — structured via logback'
            - 'OpenTelemetry — clj-otel SDK'
            - 'None'
  tooling:
    package_manager: deps-edn
    language_flavor: clojure
    test_runner: kaocha
    lint_format: clj-kondo-cljfmt
    runtime_cli: clojure
  smoke_test: |
    GET /health returns 200. One kaocha test invokes the Reitit
    handler ring-style and asserts the response.
  switch_when: |
    Need component lifecycle (Integrant), schema validation
    (malli), and OpenTelemetry by default → service-clojure.
