2 queryVPNCountriesCount,
3 queryVPNLogicalServerInfoCount,
5 } from '@proton/shared/lib/api/vpn';
12 } from '@proton/shared/lib/interfaces';
14 export const defaultVPNServersCountData: VPNServersCountData = {
15 free: { countries: 3, servers: 150 },
16 paid: { countries: 70, servers: 1900 },
19 export const getVPNServersCountData = async (api: Api) => {
20 const [serversCount, countriesCount, logicalsCount] = await Promise.all([
21 api<VPNServersCount>(queryVPNServersCount()),
22 api<VPNCountriesCount>(queryVPNCountriesCount()),
23 api<VPNLogicalsCount>(queryVPNLogicalServerInfoCount()),
26 const countFreeVPNCountries =
27 countriesCount.Counts.find((count) => count.MaxTier === 0)?.Count || defaultVPNServersCountData.free.countries;
28 const countFreeVpnServers = logicalsCount.Counts['0'];
30 const countPaidVPNServers = Math.floor(serversCount.Servers / 50) * 50;
31 const countPaidVPNCountries = Math.floor(serversCount.Countries / 5) * 5;
33 const result: VPNServersCountData = {
35 servers: countFreeVpnServers,
36 countries: countFreeVPNCountries,
39 servers: countPaidVPNServers,
40 countries: countPaidVPNCountries,