emptygif
Basa: Basa Jawa

Kabeh basa lan framework

SolidStart TypeScript

Snippet TypeScript kanggo SolidStart sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

SolidStart TypeScript

Instal
npm create solid@latest
File
pixel.ts
Lakokake
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',
    },
  });

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: SolidStart

Liyane ing TypeScript