Skip to main content
Glama
refresh.ts1.08 kB
async function main(component: Input): Promise<Output> { const token = requestStorage.getEnv("HETZNER_API_TOKEN"); if (!token) { throw new Error( "HETZNER_API_TOKEN not found (hint: you may need a secret)", ); } const resource = component.properties.resource?.payload; if (!resource) { return { status: component.properties.resource?.status ?? "error", message: "Could not refresh, no resourceId present", }; } const endpoint = _.get( component.properties, ["domain", "extra", "endpoint"], "", ); const id = component.properties?.resource?.payload.id; const response = await fetch( `https://api.hetzner.cloud/v1/${endpoint}/${id}`, { headers: { "Authorization": `Bearer ${token}`, "Content-Type": "application/json", }, }, ); if (!response.ok) { throw new Error(`API Error: ${response.status} ${response.statusText}`); } const result = await response.json(); const noun = endpoint.slice(0, -1); return { payload: result[noun], status: "ok", }; }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/systeminit/si'

If you have feedback or need assistance with the MCP directory API, please join our Discord server