emptygif
اللغة: العربية

كل اللغات وأطر العمل

AWS Lambda (Node.js) JavaScript

مقتطف بلغة JavaScript لـ AWS Lambda (Node.js) يستجيب لطلبات /pixel.gif بملف GIF الفارغ، الذي يُفك ترميزه مرة واحدة عند بدء التشغيل.

AWS Lambda (Node.js) JavaScript

الملف
index.mjs
// index.mjs - behind an API Gateway HTTP API route "GET /pixel.gif" or a function URL.
// Binary bodies travel base64-encoded, so the GIF stays in base64 here.
const GIF_BASE64 = 'R0lGODlhAQABAIAAAP///wAAACH5BAEAAAAALAAAAAABAAEAAAICRAEAOw==';

export const handler = async () => ({
  statusCode: 200,
  headers: { 'Content-Type': 'image/gif', 'Cache-Control': 'no-store' },
  body: GIF_BASE64,
  isBase64Encoded: true,
});

شغّلنا هذا المقتطف وقارنّا البايتات التي أعادها.

التحقق

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

الموقع الرسمي: AWS Lambda (Node.js)

المزيد بلغة JavaScript