Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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) {
return handleSiteMapRequest(path);
"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",
],
'use strict';
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const docClient = new AWS.DynamoDB.DocumentClient();
const tableName = process.env.TABLE_NAME;
function list_unicorns(callback) {
var params = {
TableName: tableName
};
AWSXRay.captureAsyncFunc('List Unicorns', (subsegment) => {
docClient.scan(params, function(err, data) {
// Comment or Delete the following line of code to remove simulated error
err = Error("something is wrong");
if (err) {
callback(err, null, subsegment);
import 'babel-polyfill';
const { ApolloServer, gql } = require('apollo-server-lambda');
const { RedisCache } = require('apollo-server-redis');
const { RESTDataSource } = require('apollo-datasource-rest');
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
class NYTIMESAPI extends RESTDataSource {
baseURL = ' https://api.nytimes.com/svc/search/v2/articlesearch.json';
async searchNYArticle(q) {
// https://api.nytimes.com/svc/search/v2/articlesearch.json
const result = await this.get(`?q=${q}&api-key=${process.env.NY_TIMES_APIKEY}`);
return result.response && result.response.docs ? result.response.docs : []
}
}
const typeDefs = gql`
type Query {
searchNYTimes(q: String): [Doc]
}
type Doc @cacheControl(maxAge: 6000) {
web_url: String
'use strict';
// Include the AWS X-Ray Node.js SDK and set configuration
var XRay = require('aws-xray-sdk');
var AWS = XRay.captureAWS(require('aws-sdk'));
const express = require('express');
// Constants
const PORT = 8080;
const HOST = '0.0.0.0';
AWS.config.region = process.env.REGION
XRay.config([XRay.plugins.EC2Plugin, XRay.plugins.ECSPlugin]);
// App
const app = express();
app.use(XRay.express.openSegment('name-svc'));
app.get('/*', (req, res) => {
var name = 'Arun';
// Copyright 2017 Amazon.com, Inc. or its affiliates. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License").
// You may not use this file except in compliance with the License.
// A copy of the License is located at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// or in the "license" file accompanying this file. This file is distributed
// on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
// express or implied. See the License for the specific language governing
// permissions and limitations under the License.
var XRay = require('aws-xray-sdk');
var AWS = XRay.captureAWS(require('aws-sdk'));
var http = XRay.captureHTTPs(require('http'));
const express = require('express');
var bodyParser = require('body-parser');
var queryString = require('querystring');
// Constants
const PORT = 8080;
const apiCNAME = process.env.API_CNAME || 'localhost';
// App
const app = express();
XRay.config([XRay.plugins.ECSPlugin]);
XRay.middleware.enableDynamicNaming();
'use strict';
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const docClient = new AWS.DynamoDB.DocumentClient();
exports.lambda_handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
const tableName = process.env.TABLE_NAME;
const unicorn = build_unicorn(event);
var params = {
TableName: tableName,
Item: {
name: unicorn.name,
breed: unicorn.breed,
description: unicorn.description
}
};
import 'source-map-support/register';
import AWSXray from 'aws-xray-sdk';
const AWS = AWSXray.captureAWS(require('aws-sdk'));
import { SubscriptionManager, PubSub } from 'graphql-aws-iot-server';
import schema from './root.schema';
let db;
let manager;
let pubsub;
export const handler = (event, context, callback) => {
console.log('Todo api handler running');
console.log(JSON.stringify(event));
if (!db) {
db = new AWS.DynamoDB.DocumentClient();
}
'use strict';
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const docClient = new AWS.DynamoDB.DocumentClient();
const tableName = process.env.TABLE_NAME;
exports.lambda_handler = (event, context, callback) => {
console.log('Received event:', JSON.stringify(event, null, 2));
const unicorn = build_unicorn(event);
var params = {
TableName: tableName,
Key: {
name: unicorn.name
}
};
docClient.delete(params, function(err, data) {
if (err) callback(err)
'use strict';
const co = require('co');
const AWSXRay = require('aws-xray-sdk');
const AWS = AWSXRay.captureAWS(require('aws-sdk'));
const dynamodb = new AWS.DynamoDB.DocumentClient();
const log = require('../lib/log');
const cloudwatch = require('../lib/cloudwatch');
const wrapper = require('../middleware/wrapper');
const defaultResults = process.env.defaultResults || 8;
const tableName = process.env.restaurants_table;
function* findRestaurantsByTheme(theme, count) {
let req = {
TableName: tableName,
Limit: count,
FilterExpression: "contains(themes, :theme)",
ExpressionAttributeValues: { ":theme": theme }
};