feat: stabilization + recipe edit/create UI

This commit is contained in:
clawd
2026-02-18 09:55:39 +00:00
commit ee452efa6a
75 changed files with 15160 additions and 0 deletions

View File

@@ -0,0 +1,34 @@
import { FastifyInstance } from 'fastify';
import * as svc from '../services/note.service.js';
export async function noteRoutes(app: FastifyInstance) {
app.get('/api/recipes/:id/notes', async (request) => {
const { id } = request.params as { id: string };
return svc.listNotes(id);
});
app.post('/api/recipes/:id/notes', async (request, reply) => {
const { id } = request.params as { id: string };
const { content } = request.body as { content: string };
if (!content) return reply.status(400).send({ error: 'content required' });
const note = svc.createNote(id, content);
if (!note) return reply.status(404).send({ error: 'Recipe not found' });
return reply.status(201).send(note);
});
app.put('/api/notes/:id', async (request, reply) => {
const { id } = request.params as { id: string };
const { content } = request.body as { content: string };
if (!content) return reply.status(400).send({ error: 'content required' });
const note = svc.updateNote(id, content);
if (!note) return reply.status(404).send({ error: 'Not found' });
return note;
});
app.delete('/api/notes/:id', async (request, reply) => {
const { id } = request.params as { id: string };
const ok = svc.deleteNote(id);
if (!ok) return reply.status(404).send({ error: 'Not found' });
return { ok: true };
});
}