Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
// parse body json params
app.use(restify.plugins.bodyParser({ mapParams: true }));
// set port and run server
var port = Number(process.env.VCAP_APP_PORT || 8080);
app.listen(port, function () {
log.info("listening on port: %d", port);
});
// log some custom fields
var stats = {
node_version: process.version,
pid: process.pid,
platform: process.platform,
};
log.info("runtime statistics", stats);
// handling post messages
app.post("/post_message", function (req, res, next) {
var msg = {
name: req.body.name,
time: req.body.time,
message: req.body.message,
timestamp: (new Date()).getTime()
};
req.logger.info("received message from %s", msg.name);
if (redisRunning) {
pub.publish("message", JSON.stringify(msg));
} else {
pushLocal(msg);
// host static files
app.use("/", express.static(__dirname + "/public"));
// set port and run server
var port = Number(process.env.VCAP_APP_PORT || 8080);
app.listen(port, function () {
log.info("listening on port: %d", port);
});
// log some custom fields
var stats = {
node_version: process.version,
pid: process.pid,
platform: process.platform,
};
log.info("runtime statistics", stats);
// handling post messages
app.post("/post_message", function (req, res) {
var msg = {
name: req.body.name,
time: req.body.time,
message: req.body.message,
timestamp: (new Date()).getTime()
};
req.logger.info("received message from %s", msg.name);
if (redisRunning) {
pub.publish("message", JSON.stringify(msg));
} else {
pushLocal(msg);
app.listen(port, function () {
log.info("listening on port: %d", port);
});
app.listen(port, function () {
log.info("listening on port: %d", port);
});