Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
let succeededToServerRendering = false;
let version: string;
let bundledJsForBrowserPath: string;
if (queryParamsObj && queryParamsObj.branch && queryParamsObj.branch === "master") {
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${DeployConfig.AWS_S3_PRODUCTION_FOLDER_PREFIX}/${
queryParamsObj.version
}/bundleBrowser.js`;
version = decodeURIComponent(queryParamsObj.branch);
} else if (isDevDemoRequest) {
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${
DeployConfig.AWS_S3_DEV_FOLDER_PREFIX
}/${decodeURIComponent(queryParamsObj.branch)}/bundleBrowser.js`;
version = decodeURIComponent(queryParamsObj.branch);
} else {
AWSXRay.captureHTTPsGlobal(require("http"));
AWSXRay.captureAWS(require("aws-sdk"));
version = fs.readFileSync("./version").toString("utf8");
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${
DeployConfig.AWS_S3_PRODUCTION_FOLDER_PREFIX
}/${version}/bundleBrowser.js`;
}
console.log(`The user requested at: ${path} with ${JSON.stringify(queryParamsObj)}`);
// Handling '/robots.txt' path
if (path === "/robots.txt") {
return getResponseObjectForRobot(event.headers.host === "scinapse.io");
}
// handling '/sitemap' path
if (path.search(SITEMAP_REGEX) !== -1) {
const rawCookie = event.headers.cookie;
const userType = getExpUserType(rawCookie || "");
let bundledJsForBrowserPath: string;
if (queryParamsObj && queryParamsObj.branch && queryParamsObj.branch === "master") {
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${DeployConfig.AWS_S3_PRODUCTION_FOLDER_PREFIX}/${
queryParamsObj.version
}/bundleBrowser.js`;
version = decodeURIComponent(queryParamsObj.branch);
} else if (isDevDemoRequest) {
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${
DeployConfig.AWS_S3_DEV_FOLDER_PREFIX
}/${decodeURIComponent(queryParamsObj.branch)}/bundleBrowser.js`;
version = decodeURIComponent(queryParamsObj.branch);
} else {
AWSXRay.captureHTTPsGlobal(require("http"));
AWSXRay.captureAWS(require("aws-sdk"));
version = fs.readFileSync("./version").toString("utf8");
bundledJsForBrowserPath = `${DeployConfig.CDN_BASE_PATH}/${
DeployConfig.AWS_S3_PRODUCTION_FOLDER_PREFIX
}/${version}/bundleBrowser.js`;
}
console.log(`The user requested at: ${path} with ${JSON.stringify(queryParamsObj)}`);
// Handling '/robots.txt' path
if (path === "/robots.txt") {
return getResponseObjectForRobot(event.headers.host === "scinapse.io");
}
// handling '/sitemap' path
if (path.search(SITEMAP_REGEX) !== -1) {
"use strict";
var AWSXRay = require("aws-xray-sdk");
var AWS = AWSXRay.captureAWS(require("aws-sdk"));
var GoogleStrategy = require("passport-google-oauth20").Strategy;
var jwt = require("jwt-simple");
var querystring = require("querystring");
AWSXRay.captureHTTPsGlobal(require("http"));
// global var reused across invocations
var Params = {
AuthDomainName: undefined,
AuthHashKey: undefined,
OAuthClientId: undefined,
OAuthClientSecret: undefined,
Scope: [
"https://www.googleapis.com/auth/plus.login",
"https://www.googleapis.com/auth/userinfo.email",
],
};
var requestCookie = (request, name) => {
var headers = request.headers;
// tslint:disable-next-line:no-var-requires
const AWSXRay = require('aws-xray-sdk');
// tslint:disable-next-line:no-var-requires
AWSXRay.captureHTTPsGlobal(require('http'));
import { APIGatewayEvent, Callback, Context, Handler } from 'aws-lambda';
import { sendMail } from './mailSender';
export const sendEmail: Handler = (
event: APIGatewayEvent,
context: Context,
callback?: Callback,
) => {
return sendMail(event.body).then(({ response, error }) => {
if (error) {
callback && callback(error);
} else {
callback && callback(null, response);
}
});