export const serverService = () => {
  return {
    async loadServers() {
      const response = await fetch('/servers/list.do');
      if (!response.ok) throw new Error(`Failed to fetch servers: ${response.statusText}`);

      const data = await response.json();
      if (!Array.isArray(data)) throw new Error('Invalid server data format');

      return data.map(server => ({
        id: server?.id || crypto.randomUUID(),
        name: server?.name || 'Unnamed Server',
        basePath: server?.basePath || '',
        environment: server?.environment || 'unknown'
      }));
    }
  };
};
