emptygif
Idioma: Español

Todos los lenguajes y frameworks

Hono on Bun TypeScript

Un fragmento en TypeScript para Hono on Bun que responde a las peticiones a /pixel.gif con el GIF vacío, decodificado una sola vez al arrancar.

Hono on Bun TypeScript

Instalar
bun add hono
Archivo
server.ts
Ejecutar
bun server.ts
import { Hono } from 'hono';

const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

const app = new Hono();

app.get('/pixel.gif', (c) =>
  c.body(GIF, 200, {
    'Content-Type': 'image/gif',
    'Cache-Control': 'no-store',
  }),
);

// Bun serves the default export: { fetch, port }.
export default { port: 8080, fetch: app.fetch };

Ejecutamos este fragmento y comparamos los bytes que devolvió.

Comprobar

curl -sI http://localhost:8080/pixel.gif

Sitio oficial: Hono on Bun

Más en TypeScript