A barcode within a photography* is processed so that one gets its Nutri-Score from openfoodfacts.org (JSON API ☛). For that, the following workflow is established:
- Extract from photography computable data (i.e., barcode (as number)). Extraction relies on homemade image processing versus reuse of appropriate libraries (e.g., or QuaggaJS in JavaScript).
- Compute checksum of barcode ☛ subject to extraction succeeded (correct format is 13 digits with checksum (
4
in picture) at 13th position).- Retrieve Nutri-Score from openfoodfacts.org by means of barcode (as number) provided that checksum is correct.
*JavaScript WebRTC technology allows the management of a Web camera within a browser in order to take a photography (example ☛).
Principles
- Cloudflare workers provide an environment to create self-contained (business) functions without taking care of the computing infrastructure, application server(s) typically; these functions are by definition “serverless” (Serverless Computing with Cloudflare workers ☛).
- Connection ☛ (login: see
CLOUDFLARE_EMAIL
in.env
)- A worker named
better_food
would be deployed to:https://better_food.barbierdarnal.workers.dev
How to
- Usage relies on the wrangler Command Line Interface -CLI- guide… and commands…
- Simple use case (JavaScript ) ☛
- TypeScript issues ☛
General process
wrangler login
wrangler whoami
wrangler dev # Alternative: 'wrangler dev ./ts/index.ts'
wrangler publish # Alternative: 'wrangler publish ./ts/index.ts --name better_food'
Access:
https://better_food.barbierdarnal.workers.dev
wrangler delete
Orchestration
https://www.cncf.io/blog/2021/08/25/webassembly-serverless-functions-in-aws-lambda/WebAssembly serverless functions in AWS Lambda here…
Serverless browser automation with AWS Lambda and Puppeteer here…
Serverless Puppeteer on AWS here…
https://vercel.com/docs/concepts/functions/serverless-functions/quickstart https://vercel.com/docs/concepts/functions/serverless-functions/runtimes/node-js https://www.secondstate.io/articles/vercel-wasmedge-webassembly-rust/WebAssembly serverless functions in AWS Lambda here…
Serverless browser automation with AWS Lambda and Puppeteer here…
Serverless Puppeteer on AWS here…