import { Hono } from 'hono' import { readdirSync } from 'fs' import { join } from 'path' import { capitalize } from './utils' const port = process.env.PORT ?? '3100' const app = new Hono() app.get('/:file', async c => { const file = c.req.param('file') ?? '' const fileName = (file).replace('.', '') const path = join(process.env.PWD ?? '.', `/src/${fileName}.tsx`) if (!(await Bun.file(path).exists())) return c.text('404 Not Found', 404) const page = await import(path + `?t=${Date.now()}`) return c.html(<>

<{capitalize(file)} />

) }) app.get('/', c => { return c.html(<>

Test Files

) }) function testFiles(): string[] { return readdirSync('./src') .filter(x => x.endsWith('.tsx') && !x.startsWith('index')) .map(x => x.replace('.tsx', '')) .sort() } export default { fetch: app.fetch, port }