Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var xray = require('aws-xray-sdk');
var aws = require('aws-sdk');
var serviceName = "POWER";
var servicePort = 8085;
app.use(xray.express.openSegment(serviceName));
var sqs = xray.captureAWSClient(new aws.SQS());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || servicePort;
var calcSQSQueue = process.env.CALC_SQS_QUEUE_URL
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
router.get('/', function(req, res) {
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var xray = require('aws-xray-sdk');
var aws = require('aws-sdk');
var serviceName = "SUBTRACT";
var servicePort = 8082;
app.use(xray.express.openSegment(serviceName));
var sqs = xray.captureAWSClient(new aws.SQS());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || servicePort;
var calcSQSQueue = process.env.CALC_SQS_QUEUE_URL
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
router.get('/', function(req, res) {
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var xray = require('aws-xray-sdk');
var aws = require('aws-sdk');
var serviceName = "ADD";
var servicePort = 8081;
app.use(xray.express.openSegment(serviceName));
var sqs = xray.captureAWSClient(new aws.SQS());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
// set our port
var port = process.env.PORT || servicePort;
var calcSQSQueue = process.env.CALC_SQS_QUEUE_URL
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
router.get('/', function(req, res) {
var app = express(); // define our app using express
var bodyParser = require('body-parser');
var mathsolver = require("./mathsolver.js");
var xray = require('aws-xray-sdk');
var aws = require('aws-sdk');
var serviceName = "POSTFIX";
var servicePort = 9090;
// Initializes X-Ray
xray.middleware.setSamplingRules('sampling-rules.json');
// Starts X-Ray Segment
app.use(xray.express.openSegment(serviceName));
var sqs = xray.captureAWSClient(new aws.SQS());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || servicePort;
var calcSQSQueue = process.env.CALC_SQS_QUEUE_URL
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
router.get('/', function(req, res) {
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var xray = require('aws-xray-sdk');
var aws = require('aws-sdk');
var serviceName = "DIVIDE";
var servicePort = 8084;
app.use(xray.express.openSegment(serviceName));
var sqs = xray.captureAWSClient(new aws.SQS());
// configure app to use bodyParser()
// this will let us get the data from a POST
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
var port = process.env.PORT || servicePort;
var calcSQSQueue = process.env.CALC_SQS_QUEUE_URL
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
router.get('/', function(req, res) {
'use strict'
const AWS = require('aws-sdk')
const awsXray = require('aws-xray-sdk')
const log = require('slic-tools/log.js')
const cognito = awsXray.captureAWSClient(
new AWS.CognitoIdentityServiceProvider()
)
async function get({ userId }) {
const params = {
UserPoolId: process.env.USER_POOL_ID,
Username: userId
}
log.info({ params }, 'User Pool Parameters')
const cognitoUser = await cognito.adminGetUser(params).promise()
log.info({ cognitoUser }, 'Got user')
const result = {}
cognitoUser.UserAttributes.forEach(({ Name, Value }) => {
result[Name] = Value
})
'use strict'
const awsXray = require('aws-xray-sdk')
const AWS = require('aws-sdk')
const cwEvents = awsXray.captureAWSClient(new AWS.CloudWatchEvents())
const { name: serviceName } = require('./service-info')
async function dispatchEvent(type, detail) {
const params = {
Entries: [
{
Detail: JSON.stringify(detail),
DetailType: type,
Source: serviceName
}
]
}
await cwEvents.putEvents(params).promise()
}
'use strict'
const awsXray = require('aws-xray-sdk')
const AWS = require('aws-sdk')
const log = require('./log')
const SQS = awsXray.captureAWSClient(
new AWS.SQS({ endpoint: process.env.SQS_ENDPOINT_URL })
)
const queueName = process.env.EMAIL_QUEUE_NAME
if (!queueName) {
throw new Error('EMAIL_QUEUE_NAME must be set')
} else {
log.info({ queueName }, 'Using queue')
}
async function sendEmail(message) {
const params = {
MessageBody: JSON.stringify(message),
QueueUrl: await fetchQueueUrl()
}
const AWS = require('aws-sdk')
const awsXray = require('aws-xray-sdk')
const SSM = awsXray.captureAWSClient(
new AWS.SSM({ endpoint: process.env.SSM_ENDPOINT_URL })
)
async function getUserServiceUrl() {
const result = await SSM.getParameter({ Name: 'UserServiceUrl' }).promise()
const {
Parameter: { Value: userServiceUrl }
} = result
return userServiceUrl
}
module.exports = {
getUserServiceUrl
}
'use strict'
const { middify } = require('slic-tools/middy-util')
const AWS = require('aws-sdk')
const awsXray = require('aws-xray-sdk')
const log = require('slic-tools/log')
const ses = awsXray.captureAWSClient(
new AWS.SES({
endpoint: process.env.SES_ENDPOINT_URL,
region: process.env.SES_REGION
})
)
async function sendEmail(message) {
log.info({ message }, 'sendEmail')
const { to, subject, body } = JSON.parse(message.Records[0].body)
const params = {
Destination: {
ToAddresses: [to]
},
Message: {