dryvPacks

@dryv/axum-backendv0.1.0

Axum routers and service traits with serde models for Rust backends.

Axum BackendBackendUnitPublished 7 days ago2 downloads

dryv pack add @dryv/axum-backend
2.7 KBRaw ↗
yaml
version: dryv.pack/v1alpha1
key: unit.backend.axum-backend
layout: unit
package:
  name: { $ref: "#/inputs/crate_name" }

source: templates

info:
  title: Axum Backend
  version: 0.1.0
  description: Generates serde models, semantic service traits and Axum routers for HTTP operations.

  purpose: backend
  summary: Axum routers and service traits with serde models for Rust backends.
  languages: [rust]
  frameworks: [axum, serde]
  tags: [backend, rest, http, rust]

plugins:
  - name: jinja
    extensions: [.j2]

inputs:
  repositories:
    type: boolean
    default: false
    description: Generate PostgreSQL SeaORM delegation for query and mutation operations.
  snake_case_columns:
    type: boolean
    default: false
    description: Use snake-case PostgreSQL field columns while preserving authored API names.
  crate_name:
    type: string
    default: dryv_axum_backend
    description: Cargo package name for the generated Rust library.

selections:
  policies:
    subject: policy
    scope: all
  failures:
    subject: failure
    scope: all
  enums:
    subject: property.enum
    scope: each

  models:
    subject: schema
    scope: each

  persistence-operations:
    subject: operation
    filter:
      all: { facet: http }
    scope: each

  routes:
    subject: operation
    filter:
      all: { facet: http }
    scope: collects.feature

templates:
  policies:
    $ref: "#/selections/policies"
    imports:
      - $ref: "#/templates/model"
  failures:
    $ref: "#/selections/failures"
    imports:
      - $ref: "#/templates/model"
  enum:
    $ref: "#/selections/enums"
    output:
      name: $(group.name.snake)_$(subject.name.snake)
      symbol: $(group.name.pascal)$(subject.name.pascal)

  model:
    $ref: "#/selections/models"
    output:
      name: $(group.name.snake)_$(subject.name.snake)
      symbol: $(group.name.pascal)$(subject.name.pascal)
    imports:
      - $ref: "#/templates/enum"
      - $ref: "#/templates/model"

  repository-plan:
    $ref: "#/selections/persistence-operations"
    output:
      name: $(group.name.snake)_$(subject.name.snake)

  router:
    $ref: "#/selections/routes"
    output:
      name: $(group.name.snake)_$(feature.name.snake)
      symbols:
        service: $(group.name.pascal)$(feature.name.pascal)Service
        router: build_$(group.name.snake)_$(feature.name.snake)_router
    imports:
      - $ref: "#/templates/repository-plan"
        members: true
      - $ref: "#/templates/enum"
      - $ref: "#/templates/model"

  models-index:
    exports:
      - $ref: "#/templates/enum"
      - $ref: "#/templates/model"

  routers-index:
    exports:
      - $ref: "#/templates/router"

provides:
  schema.types:
    $ref: "#/templates/model"
  property.enum.types:
    $ref: "#/templates/enum"