import { CONFIG } from '../../initializers/constants' import { doRequest } from '../../helpers/requests' export async function listIndexInstancesHost (): Promise { const uri = CONFIG.INSTANCES_INDEX.URL const qs = { healthy: true, count: 5000 } const { body } = await doRequest({ uri, qs, json: true }) return body.data.map(o => o.host as string) } export async function getMajorInstanceVersion (host: string): Promise { try { const { body } = await doRequest({ uri: `https://${host}/api/v1/config`, json: true }) const version = body.serverVersion const majorVersion = parseInt(version.split('.')[0]) return isNaN(majorVersion) ? 0 : majorVersion } catch { return 0 } }