emptygif
Basa: Basa Jawa

Kabeh basa lan framework

SvelteKit TypeScript

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

SvelteKit TypeScript

Instal
npx sv create
File
+server.ts
Lakokake
npm run dev
// src/routes/pixel.gif/+server.ts
import type { RequestHandler } from './$types';

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

export const GET: RequestHandler = () =>
  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: SvelteKit

Liyane ing TypeScript