emptygif
Ngôn ngữ: Tiếng Việt

Tất cả ngôn ngữ và framework

AdonisJS TypeScript

Đoạn mã TypeScript cho AdonisJS, trả lời các yêu cầu tới /pixel.gif bằng GIF rỗng, được giải mã một lần khi khởi động.

AdonisJS TypeScript

Cài đặt
npm init adonisjs@latest
Tệp
routes.ts
Chạy
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);
});

Chúng tôi đã chạy đoạn mã này và so sánh các byte nó trả về.

Kiểm tra

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

Trang chính thức: AdonisJS

Thêm với TypeScript