2020-02-14 14:09:31 +01:00
|
|
|
import { CONFIG } from '../initializers/constants'
|
|
|
|
import { doRequest } from '../helpers/requests'
|
|
|
|
|
2020-03-04 15:32:39 +01:00
|
|
|
async function listIndexInstancesHost (): Promise<string[]> {
|
2020-02-14 14:09:31 +01:00
|
|
|
const uri = CONFIG.INSTANCES_INDEX.URL + '/api/v1/instances/hosts'
|
|
|
|
|
|
|
|
const qs = { count: 5000 }
|
|
|
|
|
2020-03-04 15:32:39 +01:00
|
|
|
const { body } = await doRequest<any>({ uri, qs, json: true })
|
2020-02-14 14:09:31 +01:00
|
|
|
|
|
|
|
return body.data.map(o => o.host as string)
|
|
|
|
}
|
|
|
|
|
|
|
|
function getRemovedHosts (dbHosts: string[], indexHosts: string[]) {
|
|
|
|
return dbHosts.filter(dbHost => indexHosts.includes(dbHost) === false)
|
|
|
|
}
|
|
|
|
|
|
|
|
export {
|
|
|
|
getRemovedHosts,
|
|
|
|
listIndexInstancesHost
|
|
|
|
}
|