Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const AWSXRay = require('aws-xray-sdk-core');
AWSXRay.capturePromise();
// Makes sure that this function is not called again.
// It would wrap the promise prototype multiple times.
AWSXRay.capturePromise = function () { };
function captureAsyncFunc(name, func) {
return new Promise(function (resolve, reject) {
AWSXRay.captureAsyncFunc(name, (segment) => {
func(segment).then((result) => {
segment.close();
resolve(result);
}, (error) => {
segment.close(error);
reject(error);
});
});
});
}
exports.captureWithXRay = function (awsSdk) {
const xray = require('aws-xray-sdk-core');
xray.captureHTTPsGlobal(require('http'));
xray.capturePromise();
return xray.captureAWS(awsSdk);
};