emptygif
اللغة: العربية

كل اللغات وأطر العمل

Vercel Functions TypeScript

مقتطف بلغة TypeScript لـ Vercel Functions يستجيب لطلبات /pixel.gif بملف 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