emptygif
भाषा: मराठी

सर्व भाषा आणि फ्रेमवर्क

Netlify Functions TypeScript

Netlify Functions साठी TypeScript स्निपेट, जो /pixel.gif वरच्या रिक्वेस्टना empty GIF ने उत्तर देतो. GIF स्टार्टअपला एकदाच डिकोड होतो.

Netlify Functions TypeScript

इन्स्टॉल
npm i -D @netlify/functions
फाइल
pixel.mts
चालवा
netlify dev
// netlify/functions/pixel.mts
import type { Config } from '@netlify/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' };

आम्ही हा स्निपेट चालवला आणि त्याने परत केलेले बाइट्स तुलना करून पाहिले.

तपासा

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

अधिकृत साइट: Netlify Functions

TypeScript मध्ये आणखी