1Branch0Tags
GL
glucryptosync: align production template with local master
2518e512 days ago3Commits
typescript
import type { ToolProfile } from "opentool"; import { store } from "opentool/store"; import { IMPORTANT_DATES_ROUNDUP_TEMPLATE_CONFIG, requestOverrideSchema, resolveRuntimeConfig, } from "../src/config"; import { runImportantDatesRoundup } from "../src/important-dates-roundup"; export const schema = requestOverrideSchema; export const profile: ToolProfile = { description: "Upcoming important dates roundup over the gateway macro calendar.", category: "tracker", templatePreview: { subtitle: "Query upcoming important dates and return a structured roundup.", description: `Fetches upcoming dates from the gateway macro calendar. Builds a structured summary of the nearest releases and why they matter. Returns machine-readable JSON suitable for cron digests and email summaries.`, }, templateConfig: IMPORTANT_DATES_ROUNDUP_TEMPLATE_CONFIG, }; export async function POST(req: Request) { const payload = await req.json().catch(() => null); const parsed = requestOverrideSchema.safeParse(payload ?? {}); if (!parsed.success) { return new Response( JSON.stringify({ ok: false, error: parsed.error.issues[0]?.message ?? "invalid request payload", }), { status: 400, headers: { "content-type": "application/json" }, }, ); } try { const config = resolveRuntimeConfig(parsed.data); const result = await runImportantDatesRoundup(config); await store({ source: "important-dates-roundup", ref: `important-dates-roundup-${Date.now()}`, status: "info", action: "roundup", metadata: result, }); return Response.json(result); } catch (error) { const message = error instanceof Error ? error.message : "unknown"; await store({ source: "important-dates-roundup", ref: `important-dates-roundup-${Date.now()}`, status: "failed", action: "roundup", metadata: { ok: false, error: message }, }); return new Response(JSON.stringify({ ok: false, error: message }), { status: 400, headers: { "content-type": "application/json" }, }); } }