emptygif
Language: English

All languages and frameworks

SolidStart TypeScript

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

SolidStart TypeScript

Install
npm create solid@latest
File
pixel.ts
Run
npm run dev
// src/routes/pixel.gif.ts  (an API route: export HTTP method handlers)
import type { APIHandler } from '@solidjs/start/server';

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

export const GET: APIHandler = () =>
  new Response(GIF, {
    headers: {
      'Content-Type': 'image/gif',
      'Content-Length': String(GIF.length),
      'Cache-Control': 'no-store',
    },
  });

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: SolidStart

More in TypeScript