Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
var sub = redis.createClient();
// setup redis publisher and subscriber
sub.subscribe("message", "sync");
pub.on("connect", redisConnectionHandler);
sub.on("connect", redisConnectionHandler);
pub.on("end", redisEndHandler);
sub.on("end", redisEndHandler);
pub.on("error", redisErrorHandler);
sub.on("error", redisErrorHandler);
// set the logging level threshold
log.setLoggingLevel("info");
// register names of custom fields
log.registerCustomFields(["node_version", "pid", "platform"])
// parse body json params
app.use(express.json());
// add logger to the server network queue to log all incoming requests.
app.use(log.logNetwork);
// 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);
});
sub.subscribe("message", "sync");
pub.on("connect", redisConnectionHandler);
sub.on("connect", redisConnectionHandler);
pub.on("end", redisEndHandler);
sub.on("end", redisEndHandler);
pub.on("error", redisErrorHandler);
sub.on("error", redisErrorHandler);
// force logger to run restify version. (default is express, forcing express is also legal)
log.forceLogger("restify");
// set the logging level threshold
log.setLoggingLevel("info");
// register names of custom fields
log.registerCustomFields(["node_version", "pid", "platform"])
// setup serving of static files
app.get("/*", restify.plugins.serveStatic({
directory: "./public",
default: "index.html"
}));
// insert the logger as middleware to log each request.
app.use(log.logNetwork);
// 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 () {