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.

32 lines (31 loc) 1.05 kB
import { AlgorithmId } from "@smithy/types"; export { AlgorithmId }; export const getChecksumConfiguration = (runtimeConfig) => { const checksumAlgorithms = []; for (const id in AlgorithmId) { const algorithmId = AlgorithmId[id]; if (runtimeConfig[algorithmId] === undefined) { continue; } checksumAlgorithms.push({ algorithmId: () => algorithmId, checksumConstructor: () => runtimeConfig[algorithmId], }); } return { _checksumAlgorithms: checksumAlgorithms, addChecksumAlgorithm(algo) { this._checksumAlgorithms.push(algo); }, checksumAlgorithms() { return this._checksumAlgorithms; }, }; }; export const resolveChecksumRuntimeConfig = (clientConfig) => { const runtimeConfig = {}; clientConfig.checksumAlgorithms().forEach((checksumAlgorithm) => { runtimeConfig[checksumAlgorithm.algorithmId()] = checksumAlgorithm.checksumConstructor(); }); return runtimeConfig; };