emptygif
Language: English

All languages and frameworks

AdonisJS TypeScript

A TypeScript snippet for AdonisJS that answers requests for /pixel.gif with the empty GIF, decoded once at startup.

AdonisJS TypeScript

Install
npm init adonisjs@latest
File
routes.ts
Run
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);
});

We ran this snippet and compared the bytes it returned.

Check it

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

Official site: AdonisJS

More in TypeScript