emptygif
Wika: Filipino

Lahat ng language at framework

Hono on Bun TypeScript

Isang TypeScript snippet para sa Hono on Bun na sumasagot sa mga request sa /pixel.gif gamit ang empty GIF, na isang beses lang dine-decode sa startup.

Hono on Bun TypeScript

I-install
bun add hono
File
server.ts
Patakbuhin
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 };

Pinatakbo namin ang snippet na ito at ikinumpara ang mga byte na ibinalik nito.

Suriin

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

Opisyal na site: Hono on Bun

Iba pa sa TypeScript