# API Service Defaults - Moderate complexity: API service with SQLite database
# Version: 1.0.0
#
# Scenario: Single API service with SQLite database, Docker Compose deployment
# Use case: Simple APIs, MVPs, development environments

let Service = import "../schemas/service.ncl" in
let Database = import "../schemas/database.ncl" in
let Deployment = import "../schemas/deployment.ncl" in

{
  api_service_defaults = {
    project = {
      name = "api-service",
      version = "0.1.0",
      description = "API service with SQLite database",
      tags = ["api", "sqlite", "docker"],
    },

    services = {
      api = {
        type = 'api,
        image = {
          name = "api-service",
          tag = "latest",
          build_context = ".",
          dockerfile = "Dockerfile",
        },
        ports = [{
          container_port = 8080,
          host_port = 8080,
          protocol = 'tcp,
        }],
        environment = {
          LOG_LEVEL = "info",
          DATABASE_PATH = "./data/app.db",
          SERVER_HOST = "0.0.0.0",
          SERVER_PORT = "8080",
        },
        healthcheck = {
          enabled = true,
          endpoint = "/health",
          interval = 30,
          timeout = 10,
          retries = 3,
          start_period = 10,
        },
        volumes = [
          "./data:/app/data",
        ],
        restart_policy = 'unless-stopped,
        replicas = 1,
      },
    },

    database = {
      type = 'sqlite,
      sqlite = {
        database_path = "./data/app.db",
        journal_mode = 'WAL,
        synchronous = 'NORMAL,
        cache_size = -2000,
        foreign_keys = true,
      },
      migrations_path = "./migrations",
      auto_migrate = false,
    },

    deployment = {
      target = 'docker,
      docker_compose = {
        enabled = true,
        version = '3.8,
        env_file = ".env",
      },
    },

    storage = {
      docker_volumes = {
        data = {
          name = "app-data",
          driver = 'local,
          external = false,
        },
      },
    },

    network = {
      docker_networks = {
        app_network = {
          name = "app-network",
          driver = 'bridge,
          internal = false,
        },
      },
    },

    monitoring = {
      prometheus = {
        enabled = false,
      },
      grafana = {
        enabled = false,
      },
    },

    security = {
      tls = {
        enabled = false,
        auto_generate = true,
      },
      auth = {
        method = 'api_key,
        api_key = {
          header_name = "X-API-Key",
          keys = [],
        },
      },
    },
  },
}
