Skip to content
← Public packages

@kentcdodds/cloudflare-connect-pse-hyperframes

I Built Your Personal Software Ecosystem: Kent C. Dodds's Cloudflare Connect 2026 talk deck, built with HyperFrames. How Kody gives every user one of everything on Cloudflare.

FollowForkOpen app

Files

serve.mjs

19 lines · 871 B · JavaScript
// Local preview: serves the package app the way Kody mounts it, with the mount stripped.
import { createServer } from 'node:http'
import router from '../app/router.ts'

const port = Number(process.env.PORT ?? 4387)
const host = process.env.HOST ?? '0.0.0.0'
const mount = '/cloudflare-connect-pse-hyperframes'

createServer(async (req, res) => {
	if (req.url === '/') {
		res.writeHead(302, { location: mount })
		return res.end()
	}
	const url = new URL(req.url, `http://localhost:${port}`)
	if (url.pathname.startsWith(mount)) url.pathname = url.pathname.slice(mount.length) || '/'
	const response = await router.fetch(new Request(url, { method: req.method }))
	res.writeHead(response.status, Object.fromEntries(response.headers))
	res.end(Buffer.from(await response.arrayBuffer()))
}).listen(port, host, () => console.log(`Deck at http://localhost:${port}${mount}`))