refactor(services): convert fetch functions to arrow functions for consistency in Hetzner and Hostinger services

This commit is contained in:
Mauricio Siu
2025-07-23 00:43:32 -06:00
parent bd4ff2dbf2
commit 6758ef1542
2 changed files with 15 additions and 18 deletions

View File

@@ -57,9 +57,9 @@ interface HetznerServer {
};
}
export async function fetchHetznerLocations(
export const fetchHetznerLocations = async (
apiKey: string,
): Promise<HetznerLocation[]> {
): Promise<HetznerLocation[]> => {
const response = await fetch(`${HETZNER_API_URL}/locations`, {
headers: {
Authorization: `Bearer ${apiKey}`,
@@ -75,11 +75,11 @@ export async function fetchHetznerLocations(
const data = (await response.json()) as { locations?: HetznerLocation[] };
return data.locations || [];
}
};
export async function fetchHetznerServerTypes(
export const fetchHetznerServerTypes = async (
apiKey: string,
): Promise<HetznerServerType[]> {
): Promise<HetznerServerType[]> => {
const response = await fetch(`${HETZNER_API_URL}/server_types`, {
headers: {
Authorization: `Bearer ${apiKey}`,
@@ -97,11 +97,11 @@ export async function fetchHetznerServerTypes(
server_types?: HetznerServerType[];
};
return data.server_types || [];
}
};
export async function fetchHetznerServers(
export const fetchHetznerServers = async (
apiKey: string,
): Promise<HetznerServer[]> {
): Promise<HetznerServer[]> => {
const response = await fetch(`${HETZNER_API_URL}/servers`, {
headers: {
Authorization: `Bearer ${apiKey}`,
@@ -115,4 +115,4 @@ export async function fetchHetznerServers(
const data = (await response.json()) as { servers?: HetznerServer[] };
return data.servers || [];
}
};

View File

@@ -45,9 +45,9 @@ interface HostingerDataCenter {
}
// Obtener catalog items (productos VPS con precios reales)
export async function fetchHostingerCatalog(
export const fetchHostingerCatalog = async (
apiKey: string,
): Promise<HostingerCatalogItem[]> {
): Promise<HostingerCatalogItem[]> => {
const response = await fetch(
`${HOSTINGER_API_URL}/api/billing/v1/catalog?category=VPS`,
{
@@ -58,8 +58,6 @@ export async function fetchHostingerCatalog(
},
);
console.log(response);
if (!response.ok) {
throw new Error(
`Failed to fetch Hostinger catalog: ${response.statusText}`,
@@ -67,14 +65,13 @@ export async function fetchHostingerCatalog(
}
const data = (await response.json()) as HostingerCatalogItem[];
console.log(data);
return data || [];
}
};
// Obtener VPS existentes
export async function fetchHostingerServers(
export const fetchHostingerServers = async (
apiKey: string,
): Promise<HostingerServer[]> {
): Promise<HostingerServer[]> => {
const response = await fetch(
`${HOSTINGER_API_URL}/api/vps/v1/virtual-machines`,
{
@@ -92,7 +89,7 @@ export async function fetchHostingerServers(
const data = (await response.json()) as { data?: HostingerServer[] };
return data.data || [];
}
};
// Obtener data centers disponibles
export async function fetchHostingerDataCenters(