LCOV - code coverage report
Current view: top level - src/config - comfyApi.ts Coverage Total Hit
Test: ComfyUI E2E Coverage Lines: 94.7 % 19 18
Test Date: 2026-11-17 04:17:53

            Line data    Source code
       1              : import {
       2              :   configValueOrDefault,
       3              :   remoteConfig
       4              : } from '@/platform/remoteConfig/remoteConfig'
       5              : 
       6              : const PROD_API_BASE_URL = 'https://api.comfy.org'
       7         2356 : const STAGING_API_BASE_URL = 'https://stagingapi.comfy.org'
       8              : 
       9              : const PROD_CLOUD_BASE_URL = 'https://cloud.comfy.org'
      10         2356 : const STAGING_CLOUD_BASE_URL = 'https://testcloud.comfy.org'
      11              : 
      12              : const PROD_PLATFORM_BASE_URL = 'https://platform.comfy.org'
      13         2356 : const STAGING_PLATFORM_BASE_URL = 'https://stagingplatform.comfy.org'
      14              : 
      15         2356 : const BUILD_TIME_API_BASE_URL = __USE_PROD_CONFIG__
      16              :   ? PROD_API_BASE_URL
      17              :   : (import.meta.env.VITE_STAGING_API_BASE_URL ?? STAGING_API_BASE_URL)
      18              : 
      19         2356 : const BUILD_TIME_CLOUD_BASE_URL = __USE_PROD_CONFIG__
      20              :   ? PROD_CLOUD_BASE_URL
      21              :   : (import.meta.env.VITE_STAGING_CLOUD_BASE_URL ?? STAGING_CLOUD_BASE_URL)
      22              : 
      23         2356 : const BUILD_TIME_PLATFORM_BASE_URL = __USE_PROD_CONFIG__
      24              :   ? PROD_PLATFORM_BASE_URL
      25              :   : (import.meta.env.VITE_STAGING_PLATFORM_BASE_URL ??
      26              :     STAGING_PLATFORM_BASE_URL)
      27              : 
      28         9340 : function resolveBaseUrl(
      29              :   key:
      30              :     | 'comfy_api_base_url'
      31              :     | 'comfy_cloud_base_url'
      32              :     | 'comfy_platform_base_url',
      33              :   defaultValue: string
      34              : ): string {
      35         9340 :   const value = configValueOrDefault(remoteConfig.value, key, defaultValue)
      36              : 
      37         9340 :   try {
      38         9340 :     const url = new URL(value)
      39         9340 :     if (url.protocol !== 'https:' || !url.hostname) return defaultValue
      40         9340 :     return url.href.replace(/\/$/, '')
      41              :   } catch {
      42            0 :     return defaultValue
      43              :   }
      44              : }
      45              : 
      46         4436 : export function getComfyApiBaseUrl(): string {
      47         4436 :   return resolveBaseUrl('comfy_api_base_url', BUILD_TIME_API_BASE_URL)
      48              : }
      49              : 
      50         4885 : export function getComfyCloudBaseUrl(): string {
      51         4885 :   return resolveBaseUrl('comfy_cloud_base_url', BUILD_TIME_CLOUD_BASE_URL)
      52              : }
      53              : 
      54           19 : export function getComfyPlatformBaseUrl(): string {
      55           19 :   return resolveBaseUrl('comfy_platform_base_url', BUILD_TIME_PLATFORM_BASE_URL)
      56              : }
        

Generated by: LCOV version 2.0-1