emptygif
Basa: Basa Jawa

Kabeh basa lan framework

Netlify Functions TypeScript

Snippet TypeScript kanggo Netlify Functions sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

Netlify Functions TypeScript

Instal
npm i -D @netlify/functions
File
pixel.mts
Lakokake
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' };

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: Netlify Functions

Liyane ing TypeScript