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.
14 lines (13 loc) • 488 B
JavaScript
export const serializerMiddleware = (options, serializer) => (next, context) => async (args) => {
const endpoint = context.endpointV2?.url && options.urlParser
? async () => options.urlParser(context.endpointV2.url)
: options.endpoint;
if (!endpoint) {
throw new Error("No valid endpoint provider available.");
}
const request = await serializer(args.input, { ...options, endpoint });
return next({
...args,
request,
});
};