emptygif
Language: English

All languages and frameworks

Hono on Deno TypeScript

A TypeScript snippet for Hono on Deno that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

Hono on Deno TypeScript

Install
deno add jsr:@hono/hono
File
server.ts
Run
deno run --allow-net server.ts
import { Hono } from 'jsr:@hono/hono';
import { decodeBase64 } from 'jsr:@std/encoding/base64';

const GIF = decodeBase64('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==');

const app = new Hono();

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

Deno.serve({ port: 8080 }, app.fetch);

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Hono on Deno

More in TypeScript