Skip to content

Instantly share code, notes, and snippets.

@muratgozel
Created July 10, 2017 23:28
Show Gist options
  • Save muratgozel/a2568659ed8ab530ac288c7417b94d3d to your computer and use it in GitHub Desktop.
Save muratgozel/a2568659ed8ab530ac288c7417b94d3d to your computer and use it in GitHub Desktop.
const redis = require('redis')
// Create a standart redis client which will be subscriber in our case.
const sub = redis.createClient()
// Attach a listener to receive new messages as soon as subscribe to a channel.
sub.on('message', function(channel, message) {
// message is json string in our case so we are going to parse it.
try {
const json = JSON.parse(message)
// json.csrfToken is our csrfToken we have created in our frontend server!
} catch (e) {
// This error indicates that we receive a message that is not in the json format.
}
})
// Subscribe to a channel and start handling messages
sub.subscribe('parameter-mapping')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment