import { serve } from '@hono/node-server' import { serveStatic } from '@hono/node-server/serve-static' import { transformSync } from 'amaro' import { html } from 'dhtml' import { renderToString } from 'dhtml/server' import { Hono } from 'hono' const app = new Hono() app.use('/node_modules/*', serveStatic({ root: './' })) app.get('/app/:script{.+.ts}', async (c, next) => { await next() const { code } = transformSync(await c.res.text(), { mode: 'strip-only' }) c.res = c.body(code) c.res.headers.set('content-type', 'text/javascript') c.res.headers.delete('content-length') }) app.get('/app/*', serveStatic({ root: './' })) app.get('/example', c => c.html( renderToString(html`

a${'text'}b

${{ render() { return html`
${[1, 2, 3]}
` }, }} ${html`[${'A'}|${'B'}]`} `), ), ) app.get('/', async c => { const { app } = await import('./app/main.ts') return c.html( renderToString(html` dhtml ssr ${app} `), ) }) serve(app, addr => { console.log(`Listening on http://localhost:${addr.port}`) })