formatting and grist

This commit is contained in:
Darius
2026-02-06 18:59:34 +01:00
parent a8280ce27f
commit e1ef661a7a
9 changed files with 141 additions and 16 deletions

39
src/grist/routes.ts Normal file
View File

@@ -0,0 +1,39 @@
import type { GristRecord_PersonalGoals } from "@dpu/shared";
import type { FastifyInstance } from "fastify";
import { z } from "zod";
import type { GristService } from "./service";
export async function gristRoutes(
fastify: FastifyInstance,
{
gristService,
}: {
gristService: GristService;
},
) {
fastify.get(
"/grist/today",
{
schema: {
description: "Get goals for today",
tags: ["grist"],
response: {
200: z.custom<GristRecord_PersonalGoals>(),
418: z.object({
error: z.string(),
}),
},
},
},
async (_request, reply) => {
const service_result = await gristService.getToday();
if (!service_result.successful) {
reply.code(418);
return { error: service_result.result };
}
return service_result.result;
},
);
}