emptygif
Harshe: Hausa

Duk harsuna da frameworks

AdonisJS TypeScript

Snippet na TypeScript don AdonisJS da ke amsa requests zuwa /pixel.gif da empty GIF, wanda ake decoding ɗinsa sau ɗaya lokacin farawa.

AdonisJS TypeScript

Girkawa
npm init adonisjs@latest
Fayil
routes.ts
Gudanar
node ace serve --hmr
// start/routes.ts
import router from '@adonisjs/core/services/router';

const GIF = Buffer.from('R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==', 'base64');

router.get('/pixel.gif', ({ response }) => {
  response.header('Content-Type', 'image/gif');
  response.header('Cache-Control', 'no-store');
  return response.send(GIF);
});

Mun gudanar da wannan snippet kuma mun kwatanta bytes ɗin da ya mayar.

Duba shi

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

Shafin hukuma: AdonisJS

Ƙari a TypeScript