@accelerated-software-development/caddy-api-client - v0.4.3
    Preparing search index...

    Function loadConfig

    • Load a configuration file and convert it to Caddy JSON format

      Reads the file from disk, auto-detects the format (or uses the provided adapter), and uses Caddy's /adapt endpoint to convert it to JSON configuration.

      Parameters

      • path: string

        Path to the configuration file

      • Optionaladapter: CaddyAdapter

        Adapter to use (auto-detected from extension if not provided)

      • Optionaloptions: LoadConfigOptions

        Loading options (adminUrl, timeout)

      Returns Promise<Config & Record<string, unknown>>

      The parsed Caddy configuration object

      If the file content is empty or invalid

      If Caddy cannot parse the configuration

      If unable to connect to Caddy Admin API

      If the request times out

      // Auto-detect format from extension
      const config = await loadConfig("./config.json");

      // Explicitly specify adapter
      const config = await loadConfig("./my-config", "caddyfile");

      // With custom Caddy URL
      const config = await loadConfig("./Caddyfile", undefined, {
      adminUrl: "http://caddy:2019"
      });