emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Qwik City TypeScript

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

Qwik City TypeScript

Instal
npm create qwik@latest
File
index.ts
Lakokake
npm run dev
// src/routes/pixel.gif/index.ts - an endpoint: no default export, just onGet
import type { RequestHandler } from '@builder.io/qwik-city';

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

export const onGet: RequestHandler = ({ send }) => {
  send(
    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: Qwik City

Liyane ing TypeScript