emptygif
Dil: Türkçe

Tüm diller ve framework'ler

Netlify Edge Functions TypeScript

Netlify Edge Functions için, /pixel.gif isteklerine başlangıçta bir kez çözülen boş GIF ile yanıt veren bir TypeScript örneği.

Netlify Edge Functions TypeScript

Dosya
pixel.ts
Çalıştır
netlify dev
// netlify/edge-functions/pixel.ts  (runs on Deno at the edge)
import type { Config } from '@netlify/edge-functions';

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

export default () =>
  new Response(GIF, {
    headers: {
      'Content-Type': 'image/gif',
      'Content-Length': String(GIF.length),
      'Cache-Control': 'no-store',
    },
  });

export const config: Config = { path: '/pixel.gif' };

Bu örneği çalıştırıp döndürdüğü baytları karşılaştırdık.

Kontrol et

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

Resmî site: Netlify Edge Functions

TypeScript için daha fazlası