import api from '../../api'; import type { NodePayload, NodeRecord } from '../../types/node'; export const nodesApi = { async list() { const { data } = await api.get('/nodes'); return data; }, async create(payload: NodePayload) { const { data } = await api.post('/nodes', payload); return data; }, async update(id: string, payload: Partial) { const { data } = await api.put(`/nodes/${id}`, payload); return data; }, async remove(id: string) { const { data } = await api.delete<{ success: boolean }>(`/nodes/${id}`); return data; }, async setMain(id: string) { const { data } = await api.post(`/nodes/${id}/main`); return data; }, async check(id: string) { const { data } = await api.post<{ success: boolean; version?: string }>( `/nodes/${id}/check`, ); return data; }, async checkPayload(payload: NodePayload) { const { data } = await api.post<{ success: boolean; version?: string }>( '/nodes/check', payload, ); return data; }, async detectLocation(url: string) { const { data } = await api.post<{ ip?: string; host?: string; flag?: string; country?: string; countryCode?: string; }>('/nodes/detect-location', { url }); return data; }, async syncFromMain() { const { data } = await api.post<{ success: boolean; count: number }>( '/nodes/sync/main', ); return data; }, };