emptygif
Basa: Basa Jawa

Kabeh basa lan framework

React Router (framework mode, ex-Remix) TypeScript

Snippet TypeScript kanggo React Router (framework mode, ex-Remix) sing mangsuli request menyang /pixel.gif nganggo empty GIF, sing didekode sepisan nalika startup.

React Router (framework mode, ex-Remix) TypeScript

Instal
npx create-react-router@latest
File
pixel.ts
Lakokake
npm run dev
// app/routes.ts:  route('/pixel.gif', 'routes/pixel.ts')
// app/routes/pixel.ts - a resource route: a loader and no default export.
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));

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

Snippet iki wis dilakokake lan byte asile wis dibandhingake.

Priksa

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

Situs resmi: React Router (framework mode, ex-Remix)

Liyane ing TypeScript