emptygif
மொழி: தமிழ்

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

Vercel Functions TypeScript

/pixel.gif க்கு வரும் ரெக்வெஸ்ட்களுக்கு empty GIF மூலம் பதிலளிக்கும், Vercel Functions க்கான TypeScript ஸ்னிப்பெட். GIF ஸ்டார்ட்அப்பில் ஒருமுறை மட்டுமே டீகோட் செய்யப்படுகிறது.

Vercel Functions TypeScript

ஃபைல்
pixel.ts
ரன்
vercel dev
// api/pixel.ts - served at /api/pixel; map /pixel.gif to it in vercel.json:
//   { "rewrites": [{ "source": "/pixel.gif", "destination": "/api/pixel" }] }
// (In a Next.js project use an App Router route handler instead.)
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

export function GET() {
  return new Response(GIF, {
    headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
  });
}

இந்த ஸ்னிப்பெட்டை கம்பைல் அல்லது டைப்-செக் செய்தோம்.

சரிபார்

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

அதிகாரப்பூர்வ சைட்: Vercel Functions

TypeScript இல் மேலும்