emptygif
भाषा: हिन्दी

सभी भाषाएँ और फ़्रेमवर्क

TanStack Start TypeScript

TanStack Start के लिए TypeScript स्निपेट, जो /pixel.gif पर आने वाली रिक्वेस्ट का जवाब empty GIF से देता है। GIF स्टार्टअप पर एक ही बार डिकोड होता है।

TanStack Start TypeScript

इंस्टॉल
npm create @tanstack/start@latest
फ़ाइल
pixel.ts
चलाएँ
npm run dev
// src/routes/pixel[.]gif.ts  (a literal dot in a file route name is escaped as [.])
import { createFileRoute } from '@tanstack/react-router';

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

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

हमने यह स्निपेट चलाया और इसके लौटाए बाइट्स की तुलना की।

जाँचें

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

आधिकारिक साइट: TanStack Start

TypeScript में और