From 6758ef1542e236a6376da81fdf416155efc99677 Mon Sep 17 00:00:00 2001 From: Mauricio Siu <47042324+Siumauricio@users.noreply.github.com> Date: Wed, 23 Jul 2025 00:43:32 -0600 Subject: [PATCH] refactor(services): convert fetch functions to arrow functions for consistency in Hetzner and Hostinger services --- packages/server/src/services/hetzner.ts | 18 +++++++++--------- packages/server/src/services/hostinger.ts | 15 ++++++--------- 2 files changed, 15 insertions(+), 18 deletions(-) diff --git a/packages/server/src/services/hetzner.ts b/packages/server/src/services/hetzner.ts index f9bed78bd..cb55738a5 100644 --- a/packages/server/src/services/hetzner.ts +++ b/packages/server/src/services/hetzner.ts @@ -57,9 +57,9 @@ interface HetznerServer { }; } -export async function fetchHetznerLocations( +export const fetchHetznerLocations = async ( apiKey: string, -): Promise { +): Promise => { 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 { +): Promise => { 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 { +): Promise => { 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 || []; -} +}; diff --git a/packages/server/src/services/hostinger.ts b/packages/server/src/services/hostinger.ts index 5343302d5..14c98b899 100644 --- a/packages/server/src/services/hostinger.ts +++ b/packages/server/src/services/hostinger.ts @@ -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 { +): Promise => { 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 { +): Promise => { 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(