feat: implement node removal

This commit is contained in:
Aarnav Tale
2024-03-30 18:56:21 -04:00
parent 1d9f4553eb
commit a47fb61549
3 changed files with 166 additions and 78 deletions
+15
View File
@@ -48,3 +48,18 @@ export async function post<T>(url: string, key: string, body?: unknown) {
return (response.json() as Promise<T>)
}
export async function del<T>(url: string, key: string) {
const prefix = process.env.HEADSCALE_URL!
const response = await fetch(`${prefix}/api/${url}`, {
method: 'DELETE',
headers: {
Authorization: `Bearer ${key}`
}
})
if (!response.ok) {
throw new HeadscaleError(await response.text(), response.status)
}
return (response.json() as Promise<T>)
}