emptygif
Harshe: Hausa

Duk harsuna da frameworks

Qwik City TypeScript

Snippet na TypeScript don Qwik City da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

Qwik City TypeScript

Girkawa
npm create qwik@latest
Fayil
index.ts
Gudanar
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',
      },
    }),
  );
};

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: Qwik City

Ƙari a TypeScript