Repository: yusukebe/hono-htmx Branch: main Commit: 9636122a4504 Files: 8 Total size: 3.9 KB Directory structure: gitextract_aewqrsr1/ ├── .gitignore ├── README.md ├── package.json ├── src/ │ ├── components.tsx │ └── index.tsx ├── todo.sql ├── tsconfig.json └── wrangler.sample.toml ================================================ FILE CONTENTS ================================================ ================================================ FILE: .gitignore ================================================ .wrangler node_modules yarn-error.log yarn.lock wrangler.toml ================================================ FILE: README.md ================================================ # Todo Example Stack: * Hono * JSX (Hono middleware) * htmx * Zod * Cloudflare Workers * Cloudflare D1 ## Usage Install: ``` npm install ``` Setup: ``` wrangler d1 create todo wrangler d1 execute todo --local --file=todo.sql ``` Dev: ``` npm run dev ``` Deploy: ``` npm run deploy ``` ## Author Yusuke Wada ## License MIT ================================================ FILE: package.json ================================================ { "scripts": { "dev": "wrangler dev --live-reload src/index.tsx", "deploy": "wrangler deploy --minify src/index.tsx" }, "dependencies": { "@hono/zod-validator": "^0.1.9", "hono": "^3.8.0-rc.2", "zod": "^3.21.4" }, "devDependencies": { "@cloudflare/workers-types": "^4.20231002.0", "wrangler": "^3.11.0" } } ================================================ FILE: src/components.tsx ================================================ import { html } from 'hono/html' import { jsxRenderer } from 'hono/jsx-renderer' export const renderer = jsxRenderer(({ children }) => { return html`
{title}
) ================================================ FILE: src/index.tsx ================================================ import { Hono } from 'hono' import { z } from 'zod' import { zValidator } from '@hono/zod-validator' import { renderer, AddTodo, Item } from './components' type Bindings = { DB: D1Database } type Todo = { title: string id: string } const app = new Hono<{ Bindings: Bindings }>() app.get('*', renderer) app.get('/', async (c) => { const { results } = await c.env.DB.prepare(`SELECT id, title FROM todo;`).all