emptygif
Lingua: Italiano

Tutti i linguaggi e framework

Hono on Deno TypeScript

Uno snippet TypeScript per Hono on Deno che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.

Hono on Deno TypeScript

Installa
deno add jsr:@hono/hono
File
server.ts
Esegui
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);

Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.

Verifica

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

Sito ufficiale: Hono on Deno

Altro in TypeScript