Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
init: function (config, eventEmitter) {
console.log('Connecting to nats on: ' + config.servers.join(', '));
nats = nats.connect(config);
nats.on('error', function(err) {
console.error('NATS: ' + err);
});
eventEmitter.on('event', function(event) {
var subject,
action,
cachePrefix = config.cachePrefix;
if (event.schema && event.table) {
subject = event.schema + '.' + event.table + (event.pk ? ('.' + event.pk) : '');
} else if (event.ns && event.pk) {
subject = event.ns + '.' + event.pk;
}
nats.publish(subject, config.publishEventData ? JSON.stringify(event) : null);