/** * Copyright (c) 2025 favewa * SPDX-License-Identifier: BSD-3-Clause */ import { createRouter } from "cobweb/routing"; import { Defer, render } from "cobweb/jsx-runtime"; interface Todo { id: string; text: string; done: boolean; createdAt: Date; } const todos: Todo[] = [ { id: "1", text: "meow", done: true, createdAt: new Date() }, { id: "2", text: "mrrp", done: false, createdAt: new Date() }, { id: "3", text: "mrrp", done: false, createdAt: new Date() }, { id: "4", text: "mrrp", done: false, createdAt: new Date() }, ]; async function* fetchTodos(): AsyncGenerator { for (const todo of todos) { await new Promise((r) => setTimeout(r, 300)); yield todo; } } const Layout = (props: { title: string; children: any }) => ( {props.title} {props.children} ); const TodoList = async function* (): AsyncGenerator { yield
Loading todos...
; for await (const todo of fetchTodos()) { yield (
{todo.text}
); } }; const app = createRouter(); app.get("/", async (ctx) => { const { html } = ctx; await render(

My Todos

, html.chunks, ); return html.response; }); app.get("/meow/:test?", async (ctx) => { console.log(ctx.params.test); }); Deno.serve({ port: 8000 }, app.fetch);