Files
legion_kk/scripts/fetch-hcloud-spec.mjs
2026-04-09 20:01:17 +02:00

20 lines
628 B
JavaScript

import { mkdir, writeFile } from "node:fs/promises"
import { dirname, resolve } from "node:path"
const sourceUrl =
"https://github.com/MaximilianKoestler/hcloud-openapi/raw/refs/heads/main/openapi/hcloud.json"
const targetPath = resolve(process.cwd(), "hey-api/backend/hcloud.json")
const response = await fetch(sourceUrl)
if (!response.ok) {
throw new Error(`Failed to download the Hetzner OpenAPI spec: ${response.status}`)
}
const body = await response.text()
await mkdir(dirname(targetPath), { recursive: true })
await writeFile(targetPath, body, "utf8")
console.log(`Saved Hetzner OpenAPI spec to ${targetPath}`)