Qwik City TypeScript
Uno snippet TypeScript per Qwik City che risponde alle richieste a /pixel.gif con la GIF vuota, decodificata una sola volta all'avvio.
Qwik City TypeScript
// src/routes/pixel.gif/index.ts - an endpoint: no default export, just onGet
import type { RequestHandler } from '@builder.io/qwik-city';
const GIF = Uint8Array.from(atob('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw=='), (c) => c.charCodeAt(0));
export const onGet: RequestHandler = ({ send }) => {
send(
new Response(GIF, {
headers: {
'Content-Type': 'image/gif',
'Content-Length': String(GIF.length),
'Cache-Control': 'no-store',
},
}),
);
};
Abbiamo eseguito questo snippet e confrontato i byte che ha restituito.
Verifica
curl -sI http://localhost:8080/pixel.gif
Altro in TypeScript
- Next.js (App Router)
- Hono
- Bun.serve
- Elysia
- Deno.serve
- SvelteKit
- Nuxt (Nitro server route)
- Astro
- React Router (framework mode, ex-Remix)
- TanStack Start
- SolidStart
- Hono on Bun
- Hono on Deno
- srvx (universal fetch server)
- RedwoodSDK
- Angular SSR (Express server.ts)
- Fresh
- Oak
- Encore.ts
- NestJS
- AdonisJS
- Cloudflare Workers
- Cloudflare Pages Functions
- Deno Deploy (deno serve)
- Vercel Functions
- Netlify Functions
- Netlify Edge Functions
- Deno one-liner