Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// Include the AWS X-Ray Node.js SDK and set configuration
//ref: https://docs.aws.amazon.com/xray-sdk-for-nodejs/latest/reference/
const XRay = require('aws-xray-sdk');
const AWS = XRay.captureAWS(require('aws-sdk'));
const http = XRay.captureHTTPs(require('http'));
const express = require('express');
// const request = require('sync-request');
// Constants
const PORT = 8080;
const HOST = '0.0.0.0';
AWS.config.region = process.env.REGION
XRay.config([XRay.plugins.EC2Plugin, XRay.plugins.ECSPlugin]);
//XRay.middleware.setSamplingRules('sampling-rules.json');
XRay.middleware.enableDynamicNaming('*.elb.amazonaws.com');
// App
const app = express();
app.use(XRay.express.openSegment('webapp'));
app.get('/', (req, res) => {
let seg = XRay.getSegment();
seg.addAnnotation('param_greet', req.query['greet']);
seg.addAnnotation('param_id', req.query['id']);
getContent({hostname:`${process.env.GREETER_SERVICE_HOST}` ,port:process.env.GREETER_SERVICE_PORT, path: `/${process.env.GREETER_SERVICE_PATH}?greet=${req.query['greet']}`})
.then( function (html){
console.log (html);
var output1 = html;
// console.log(`output = ${output1}`);
getContent({hostname:`${process.env.NAME_SERVICE_HOST}` ,port:process.env.NAME_SERVICE_PORT, path: `/${process.env.NAME_SERVICE_PATH}?id=${req.query['id']}`})
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();
app.use(bodyParser.urlencoded({extended: false}));
app.use(XRay.express.openSegment('service-a'));
app.get('/health', function(req, res) {
res.status(200).send("Healthy");
});
app.get('/', function(req, res) {
var seg = XRay.getSegment();
seg.addAnnotation('service', 'service-b-request');
var reqData = queryString.stringify(req.body);
var options = {
host: apiCNAME,
var http = XRay.captureHTTPs(require('http')); // Capture all HTTP/HTTPS calls
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.EC2Plugin, XRay.plugins.ECSPlugin]);
XRay.middleware.enableDynamicNaming();
app.use(bodyParser.urlencoded({extended: false}));
// Start capturing the calls in the application
app.use(XRay.express.openSegment('service-a'));
app.get('/health', function(req, res) {
res.status(200).send("Healthy");
});
app.get('/', function(req, res) {
var seg = XRay.getSegment();
seg.addAnnotation('service', 'service-b-request');
var reqData = queryString.stringify(req.body);
// 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'));
const express = require('express');
// Constants
const PORT = 8080;
// App
const app = express();
XRay.config([XRay.plugins.EC2Plugin, XRay.plugins.ECSPlugin]);
XRay.middleware.enableDynamicNaming();
app.use(XRay.express.openSegment('service-b'));
function randomIntInc(low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}
function sleep(callback) {
var now = new Date().getTime();
while (new Date().getTime() < now + randomIntInc(0, 1000)) { /* */ }
callback();
}
app.get('/health', function(req, res) {
res.status(200).send("Healthy");
});
var express = require('express'); // call express
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
// 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'));
const express = require('express');
// Constants
const PORT = 8080;
// App
const app = express();
XRay.config([XRay.plugins.ECSPlugin]);
XRay.middleware.enableDynamicNaming();
app.use(XRay.express.openSegment('service-b'));
function randomIntInc(low, high) {
return Math.floor(Math.random() * (high - low + 1) + low);
}
function sleep(callback) {
var now = new Date().getTime();
while (new Date().getTime() < now + randomIntInc(0, 1000)) { /* */ }
callback();
}
app.get('/health', function(req, res) {
res.status(200).send("Healthy");
});
var express = require('express');
var app = express();
var bodyParser = require('body-parser');
var mathsolver = require("./mathsolver.js");
var calcmetrics = require("./calcmetrics.js");
var xray = require('aws-xray-sdk');
var querystring = require('querystring');
var shortid = require('shortid');
var serviceName = "CALCULATOR";
var servicePort = 8080;
xray.middleware.setSamplingRules('sampling-rules.json');
var http = xray.captureHTTPs(require('http'));
app.use(xray.express.openSegment(serviceName));
// 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;
// ROUTES FOR OUR API
// =============================================================================
var router = express.Router();
// test route to make sure everything is working (accessed at GET http://localhost:8080/api)
module.exports.bind = function (app) {
AWSXRay.enableManualMode()
AWSXRay.setLogger(logger)
AWSXRay.middleware.setSamplingRules('aws-xray.rules')
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
app.use(AWSXRay.express.openSegment('pay_selfservice'))
createNamespace(clsXrayConfig.nameSpaceName)
app.get('/style-guide', (req, res) => response(req, res, 'style_guide'))
// APPLY CORRELATION MIDDLEWARE
app.use('*', correlationIdMiddleware, getRequestContext)
app.use((req, res, next) => {
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
namespace.bindEmitter(req)
namespace.bindEmitter(res)
namespace.run(() => {
next()
exports.bind = function (app) {
AWSXRay.enableManualMode()
AWSXRay.setLogger(logger)
AWSXRay.middleware.setSamplingRules('aws-xray.rules')
AWSXRay.config([AWSXRay.plugins.ECSPlugin])
app.use(AWSXRay.express.openSegment('pay_frontend'))
createNamespace(clsXrayConfig.nameSpaceName)
app.use((req, res, next) => {
const namespace = getNamespace(clsXrayConfig.nameSpaceName)
namespace.bindEmitter(req)
namespace.bindEmitter(res)
namespace.run(() => {
next()
})
})
app.get('/healthcheck', healthcheck)
var XRay = require('aws-xray-sdk');
XRay.middleware.setSamplingRules('sampling-rules.json');
//XRay.middleware.enableDynamicNaming();
var http = XRay.captureHTTPs(require('http'));
String.prototype.isNumeric = function() {
return !isNaN(parseFloat(this)) && isFinite(this);
}
Array.prototype.clean = function() {
for(var i = 0; i < this.length; i++) {
if(this[i] === "") {
this.splice(i, 1);
}
}
return this;
}