UNPKG

serverless-spy

Version:

CDK-based library for writing elegant integration tests on AWS serverless architecture and an additional web console to monitor events in real time.

17 lines (16 loc) 612 B
import { EndpointError } from "../types"; import { callFunction } from "./callFunction"; import { evaluateTemplate } from "./evaluateTemplate"; import { getReferenceValue } from "./getReferenceValue"; export const evaluateExpression = (obj, keyName, options) => { if (typeof obj === "string") { return evaluateTemplate(obj, options); } else if (obj["fn"]) { return callFunction(obj, options); } else if (obj["ref"]) { return getReferenceValue(obj, options); } throw new EndpointError(`'${keyName}': ${String(obj)} is not a string, function or reference.`); };