view benchmark/bun-http-framework-benchmark/src/bun/byte.ts @ 263:ee04e4e69fed

Add functional JRPG frame and tools Add full-screen background_2 apertures, functional frame chrome, card-driven details, dual-window tools, live conversion workflows, and bounded cleanup for generated downloads. Co-authored-by: Copilot <[email protected]>
author MrJuneJune <mrjunejune@users.noreply.github.com>
date Thu, 06 Aug 2026 11:31:30 -0700
parents a8976a008a9d
children
line wrap: on
line source

import { Byte, query, send } from '@bit-js/byte'

const xPoweredBy = ['X-Powered-By', 'benchmark'] as [string, string]

// Extract the 'name' parameter value from query
const getName = query.get('name')

// Serve directly
export default new Byte()
	.get('/', send.body('Hi'))
	// Send ID with query
	.get('/id/:id', (ctx) => {
		ctx.headers.push(xPoweredBy)
		return ctx.body(`${ctx.params.id} ${getName(ctx)}`)
	})
	// Yield body
	.post('/json', async (ctx) => ctx.json(await ctx.req.json()))