CodeIssuesDiscussionsWikiPull RequestsProjectsCommitsActionsReleasesContributorsPulse● GatesSecuritySettingsDeploymentsPipelineInsightsAgents✨ Explain✨ Ask AI✨ Workspace✨ Spec✨ Tests▓ Debt Map✨ NL Search🏛 Archaeology
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | import { Hono } from "hono";
type Todo = { id: number; title: string; done: boolean };
const app = new Hono();
const todos: Todo[] = [
{ id: 1, title: "Try GlueCron", done: false },
{ id: 2, title: "Push a commit", done: false },
];
app.get("/health", (c) => c.json({ ok: true }));
app.get("/todos", (c) => c.json(todos));
app.post("/todos", async (c) => {
const body = await c.req.json<{ title?: string }>();
if (!body?.title) return c.json({ error: "title required" }, 400);
const todo: Todo = { id: todos.length + 1, title: body.title, done: false };
todos.push(todo);
return c.json(todo, 201);
});
export default app;
|