Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { env } from '../common/environment';
import * as InternalTypes from '../common/internal-message-types';
import { invokeMessengerReply } from '../common/lambda-utils';
import * as Subscription from '../models/subscription';
import * as ActionHelper from './action-helper';
import * as NextEpisodeController from './controllers/next-episode.controller';
import * as SearchController from './controllers/search.controller';
import * as TrendingController from './controllers/trending.controller';
const { ActionTypes, ReplyKind } = InternalTypes;
if (!process.env.IS_LOCAL) {
// tslint:disable-next-line: no-console
console.log('capturing outgoing http calls in X-Ray');
// tslint:disable-next-line no-var-requires
AWSXRay.captureHTTPsGlobal(require('http'));
}
export async function handler(
action: InternalTypes.AnyAction,
context: {},
callback: LambdaCallback,
): Promise {
if (env !== 'test') {
console.log('entry'); // tslint:disable-line:no-console
prettyPrint(action);
}
const socialId = ActionHelper.getSocialId(action);
// compute the reply
let reply;
import { LambdaCallback } from '../common/aws-lambda-types';
import { getError } from '../common/common-utils';
import { errorMessages } from '../common/constants';
import { env } from '../common/environment';
import * as InternalTypes from '../common/internal-message-types';
import * as MessengerTypes from '../common/messenger-types';
import * as MessengerAPI from '../common/messenger.api';
import { generateGenericTemplate } from './messenger.formatter';
const { ReplyKind } = InternalTypes;
if (!process.env.IS_LOCAL) {
// tslint:disable-next-line: no-console
console.log('capturing outgoing http calls in X-Ray');
// tslint:disable-next-line no-var-requires
AWSXRay.captureHTTPsGlobal(require('http'));
}
export async function handler(
reply: InternalTypes.AnyReplyKind,
context: {},
callback: LambdaCallback,
): Promise {
if (env !== 'test') {
console.log('input', JSON.stringify(reply)); // tslint:disable-line:no-console
}
if (isEmpty(reply.metaData)) {
return callback(new Error('no metaData'));
}
const metaData = reply.metaData.fbMessenger;
if (isEmpty(metaData)) {
const AWSXRay = require("aws-xray-sdk-core");
AWSXRay.captureHTTPsGlobal(require("https"), true);
const { URL } = require("url");
const chromeLambda = require("chrome-aws-lambda");
const MrPuppetshot = require("mrpuppetshot");
const normalizeEvent = require("./helpers/normalizeEvent");
const S3Bucket = require("./helpers/s3bucket");
// Defaults
const CHROMIUM_ARGS = JSON.parse(process.env.CHROMIUM_ARGS || "[]");
const TIMEOUT = Number(process.env.TIMEOUT) || 30 * 1000;
const IGNORE_HTTPS_ERRORS = process.env.IGNORE_HTTPS_ERRORS === "true";
const VIEWPORT_WIDTH = Number(process.env.VIEWPORT_WIDTH) || 1920;
const VIEWPORT_HEIGHT = Number(process.env.VIEWPORT_HEIGHT) || 1200;
const DEVICE_SCALE_FACTOR = Number(process.env.DEVICE_SCALE_FACTOR) || 1;
const IS_MOBILE = process.env.IS_MOBILE === "true";
const IS_LANDSCAPE = process.env.IS_LANDSCAPE === "true";
exports.captureWithXRay = function (awsSdk) {
const xray = require('aws-xray-sdk-core');
xray.captureHTTPsGlobal(require('http'));
xray.capturePromise();
return xray.captureAWS(awsSdk);
};