Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
};
sqs.sendMessage(params, function(err, data) {
if (err) {
console.log(`sqs error for ${serviceName} service`, data.MessageId);
} else {
console.log(`sqs success for ${serviceName} service`, data.MessageId);
}
});
});
// REGISTER OUR ROUTES -------------------------------
// all of our routes will be prefixed with /api
app.use('/api', router);
app.use(xray.express.closeSegment());
// START THE SERVER
// =============================================================================
app.listen(port);
console.log(`${serviceName} service listening on port: ` + port);
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
// =============================================================================
var router = express.Router();
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");
});
app.post('/create', 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();
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()
})
})
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();
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");
});
app.post('/create', 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();
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();
app.get('/*', (req, res) => {
var greet = 'Hello';
var seg = XRay.getSegment();
seg.addAnnotation('greet_req', req.query['greet']);
console.log('greet[greet]: ' + req.query['greet']);
if (req.query['greet'] == 'ho') {
greet = 'Howdy';
}
res.send(greet);
});
app.use(XRay.express.closeSegment());
app.listen(PORT, HOST);
console.log(`Running on http://${HOST}:${PORT}`);