# This file is auto-generated by alef — DO NOT EDIT.
# alef:hash:4e15143f4af1ae8bafbdb1506ef057da924484c66a19483966333558ad437e75
# To regenerate: alef generate
# To verify freshness: alef verify --exit-code
# Issues & docs: https://github.com/kreuzberg-dev/alef
defmodule Kreuzberg.ServerConfig do
  @moduledoc """
  API server configuration.

  This struct holds all configuration options for the Kreuzberg API server,
  including host/port settings, CORS configuration, and upload limits.

  # Defaults

  - `host`: "127.0.0.1" (localhost only)
  - `port`: 8000
  - `cors_origins`: empty vector (allows all origins)
  - `max_request_body_bytes`: 104_857_600 (100 MB)
  - `max_multipart_field_bytes`: 104_857_600 (100 MB)
  """

  @typedoc "API server configuration."
  @type t :: %__MODULE__{
          host: String.t() | nil,
          port: non_neg_integer(),
          cors_origins: [String.t()],
          max_request_body_bytes: non_neg_integer(),
          max_multipart_field_bytes: non_neg_integer()
        }

  defstruct host: nil,
            port: 0,
            cors_origins: [],
            max_request_body_bytes: 0,
            max_multipart_field_bytes: 0

  defimpl Jason.Encoder do
    @doc false
    def encode(value, opts) do
      value
      |> Map.from_struct()
      |> Enum.reject(fn {_k, v} -> v == nil end)
      |> Enum.into(%{})
      |> Jason.Encoder.encode(opts)
    end
  end
end
