emptygif
மொழி: தமிழ்

அனைத்து மொழிகளும் ஃப்ரேம்வொர்க்குகளும்

TanStack Start TypeScript

/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், TanStack Start க்கான TypeScript ஸ்னிப்பெட். 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 இல் மேலும்