emptygif
Language: English

All languages and frameworks

Fresh TypeScript

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

Fresh TypeScript

Install
deno run -Ar jsr:@fresh/init
File
main.ts
Run
deno task dev
// main.ts - a programmatic route (Fresh 2)
import { App } from 'fresh';
import { decodeBase64 } from 'jsr:@std/encoding/base64';

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

export const app = new App()
  .get('/pixel.gif', () =>
    new Response(GIF, {
      headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
    }))
  .fsRoutes();

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: Fresh

More in TypeScript