1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import { z } from "zod";
import { withErrors, ok, apiError, parseJson } from "@/lib/api";
import { requireUser } from "@/lib/auth";
import { runOsa } from "@/lib/mac";
// Things to-do ids are alphanumeric with dashes — validate before embedding.
const Body = z.object({ id: z.string().regex(/^[A-Za-z0-9-]+$/) });
// POST /api/integrations/things/complete — mark a Things 3 to-do completed.
export const POST = withErrors(async (req) => {
await requireUser(req);
const { id } = await parseJson(req, Body).catch(() => ({ id: "" }));
if (!id) return apiError("invalid_input", "Bad todo id", 400);
await runOsa(`tell application "Things3" to set status of to do id "${id}" to completed`);
return ok({ ok: true });
});
|