Hono-Zod-OpenAPI with Fiberplane API Playground integration
16
17 const load = async () => {
18 const res = await fetch("/api/todos");
19 const data: Todo[] = await res.json();
20 setTodos(data);
27 const add = async (e: React.FormEvent) => {
28 e.preventDefault();
29 await fetch("/api/todos", {
30 method: "POST",
31 headers: { "Content-Type": "application/json" },
37
38 const complete = async (id: number) => {
39 await fetch("/api/complete", {
40 method: "POST",
41 headers: { "Content-Type": "application/json" },
44 const url = new URL(req.url);
45 const data = await req.json();
46 if (url.pathname.endsWith("/api/todos")) {
47 db.prepare("INSERT INTO todos (text) VALUES (?)").run(data.text);
48 return new Response("ok");
49 }
50 if (url.pathname.endsWith("/api/complete")) {
51 const id = data.id;
52 const today = getToday();