Skip to content

Instantly share code, notes, and snippets.

@devalexandre
Created November 9, 2021 04:55
Show Gist options
  • Save devalexandre/8e402c603c06cf5da79d207d0c6791d2 to your computer and use it in GitHub Desktop.
Save devalexandre/8e402c603c06cf5da79d207d0c6791d2 to your computer and use it in GitHub Desktop.
const seneca = require('seneca')();
seneca
.use('seneca-redis-transport')
.add({
role:"math",
cmd:"calcAge"
},(msg,reply)=>{
const oldYear = msg.year || 0
const currentYear = new Date().getFullYear()
const age = currentYear - oldYear
seneca.client({
type:"redis",
topic: "notify"
}).act({role:"notify",cmd:"send",text:age})
reply(null,{
answer:age
})
})
.listen({
type: "redis",
topic: "math",
host: 'localhost',
port: 6379
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment