Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
if (cachePrefix) {
action = event.type === 'update' ? 'invalidate.' : event.action === 'delete' ? 'purge.' : 'populate.';
nats.publish(cachePrefix + action + subject);
}
});
},
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);
if (cachePrefix) {
action = event.type === 'update' ? 'invalidate.' : event.action === 'delete' ? 'purge.' : 'populate.';
nats.publish(cachePrefix + action + subject);
}
});
},