A small helper that lets one FOMO service call another Lambda using a fetch-like API and an aws-lambda:// URL convention (e.g. aws-lambda://my-function/path?query=1). It parses the URL into an API Gateway-style event, invokes the target Lambda synchronously, and returns a response object with .text() and .json() helpers.
- Node.js
@aws-sdk/client-lambda(LambdaInvokeCommand)
npm installsetDefaultOptions({ functionNameTransform }) can be used to map logical function names to deployed names (e.g. add a stage suffix). No environment variables are required; AWS credentials are taken from the standard SDK chain.
const { backendFetch, setDefaultOptions } = require("backend-fetch");
const res = await backendFetch("aws-lambda://auth/token", { method: "post", body: "..." });
const data = await res.json();Library — consumed by other services, not deployed standalone.