Skip to content
← Public packages

@kentcdodds/closing-the-agentic-loop

Closing the Agentic Loop: Kent C. Dodds's talk and workshop deck. Default short talk; ?event=aie-2026 is the AIE hour cut with a Podium QR; ?format=full adds labs.

FollowForkOpen app

Files

router.ts

38 lines · 1.3 KB · TypeScript
import { assets, slideCount, type Asset } from './assets.generated.ts'

function body(asset: Asset): BodyInit {
	if (asset.text != null) return asset.text
	const bin = atob(asset.base64 ?? '')
	const bytes = new Uint8Array(bin.length)
	for (let i = 0; i < bin.length; i++) bytes[i] = bin.charCodeAt(i)
	return bytes
}

function respond(path: string, method: string, status = 200) {
	const asset = assets[path]!
	return new Response(method === 'HEAD' ? null : body(asset), {
		status,
		headers: {
			'content-type': asset.type,
			'cache-control': path === 'index.html' ? 'no-cache' : 'public, max-age=3600',
			'x-content-type-options': 'nosniff',
		},
	})
}

/**
 * The deck is one self-contained page (fonts and images inlined), so the app only
 * serves index.html, a favicon and /health. Kody strips the package mount before
 * forwarding; nothing here depends on the prefix.
 */
export default {
	async fetch(request: Request): Promise<Response> {
		if (request.method !== 'GET' && request.method !== 'HEAD') {
			return new Response('Method not allowed', { status: 405 })
		}
		const { pathname } = new URL(request.url)
		if (pathname.endsWith('/favicon.ico')) return respond('favicon.ico', request.method)
		if (pathname.endsWith('/health')) return Response.json({ ok: true, slides: slideCount })
		return respond('index.html', request.method)
	},
}