This is a sample working Node.js function that's designed to check the availability of the coveted LEGO UCS AT-AT product on the official website using Puppeteer and Chromium. It performs synthetic monitoring by simulating a visit to the product's page and checks the product's availability based on Schema.org data. It then takes a screenshot and uploads to storage for later viewing pleasure.
- An Appwrite server setup and running.
- A project created in Appwrite with this function added.
Create a new function in your Appwrite console. Choose the Node.js runtime.
In the function settings in the Appwrite console, add an environment variable:
- Key:
PUPPETEER_EXECUTABLE_PATH
- Value:
/usr/bin/chromium-browser
This variable instructs Puppeteer to use the Chromium browser installed on the server.
In the function's Configuration > Build Settings, add the following command:
apk update && apk fetch chromium nss freetype harfbuzz ca-certificates ttf-freefont && npm i