emptygif
భాష: తెలుగు

అన్ని భాషలు, ఫ్రేమ్‌వర్క్‌లు

RedwoodSDK TypeScript

/pixel.gif కు వచ్చే రిక్వెస్ట్‌లకు empty GIF తో జవాబిచ్చే, RedwoodSDK కోసం TypeScript స్నిపెట్. GIF స్టార్టప్‌లో ఒక్కసారే డీకోడ్ అవుతుంది.

RedwoodSDK TypeScript

ఇన్‌స్టాల్
npx create-rwsdk my-app
ఫైల్
worker.tsx
రన్
npm run dev
// src/worker.tsx - a route before render() answers with its own Response
import { render, route } from 'rwsdk/router';
import { defineApp } from 'rwsdk/worker';

import { Document } from '@/app/document';
import { Home } from '@/app/pages/home';

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

export default defineApp([
  route('/pixel.gif', () =>
    new Response(GIF, {
      headers: {
        'Content-Type': 'image/gif',
        'Content-Length': String(GIF.length),
        'Cache-Control': 'no-store',
      },
    }),
  ),
  render(Document, [route('/', Home)]),
]);

మేము ఈ స్నిపెట్‌ను రన్ చేసి, అది తిరిగి ఇచ్చిన బైట్‌లను పోల్చి చూశాం.

చెక్ చేయండి

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

అధికారిక సైట్: RedwoodSDK

TypeScript లో మరిన్ని