import axios from 'axios' const api = axios.create({ baseURL: '/api/v1', headers: { 'Content-Type': 'application/json', }, }) // Types export interface Server { id: string name: string template: string pillar: string provider: string ip_address: string status: 'provisioning' | 'starting' | 'active' | 'draining' | 'stopping' | 'stopped' | 'error' created_at: string updated_at: string } export interface AdminUser { id: string email: string created_at: string } export interface Bucket { id: string public: boolean } export interface StorageObject { name: string metadata?: { size: number mimetype: string } } export interface DbTable { schema: string name: string } export interface EdgeFunction { name: string runtime: string code?: string } export interface Template { id: string name: string description: string min_hetzner_plan: string estimated_monthly_cost: number services: Service[] requirements: TemplateRequirements } export interface Service { id: string name: string image: string ports: string[] } export interface TemplateRequirements { min_nodes: number max_nodes: number supports_ha: boolean } export interface Provider { name: string provider: string supported: boolean plans: Plan[] regions: number } export interface Plan { id: string name: string cpu_cores: number memory_gb: number disk_gb: number monthly_cost: number } export interface ClusterHealth { healthy: boolean total_servers: number active_servers: number error_servers: number services_up: number services_down: number } export interface ScalingPlan { scaling_plan: ScalingStep[] total_cost_monthly: number estimated_time_minutes: number } export interface ScalingStep { provider: string action: string template: string plan: string count: number cost_per_server: number total_cost: number } export const apiService = { // Servers getServers: () => api.get('/servers'), getServer: (id: string) => api.get(`/servers/${id}`), addServer: (data: AddServerRequest) => api.post('/servers', data), removeServer: (id: string) => api.delete(`/servers/${id}`), fortifyServer: (id: string, data: FortifyRequest) => api.post(`/servers/${id}/fortify`, data), // Templates getTemplates: () => api.get('/templates'), getTemplate: (id: string) => api.get