Feathersjs VS Senecajs

Viewed 1367

I've been playing with Seneca microservice and feathersjs. Both share some level of similarities. I tried the examples of both seneca and feathers. Feathers has few advantages like

  • Simple and nice CLI Generator
  • Hooks
  • Nice Documentation.

And the drawback is it's coupled with Express. it should be independent like Seneca.

Below is the code of simple example using Seneca. it's run on different ports and seems like all services are independent to each other. Seneca is more like independent. I also found one amazing repository on git Ramanujan.

I want to know the advantages and disadvantages of both. It's really bad to compare both but my goal is to use one of them to make API.

So I'm quite confused about which one to choose.

server.js

seneca.add({cmd: 'config'}, function (msg, done) {
  var config = {rate: 0.23}
  var value = config[msg.prop]
  done(null, {value: value})
})

// local rates
seneca.add({cmd: 'salestax', country: 'US'}, function (msg, done) {
  var state = {
    'NY': 0.04,
    'CA': 0.0625
    // ...
  }
  var rate = state[msg.state]
  var total = msg.net * (1 + rate)
  done(null, {total: total})
})
.listen({"type": "http", "port": 10101});


// categories
seneca.add({ cmd: 'salestax', country: 'IE' }, function (msg, done) {
  var category = {
    'top': 0.23,
    'reduced': 0.135
    // ...
  }
  var rate = category[msg.category]
  var total = msg.net * (1 + rate)
  done(null, { total: total })
})
.listen({"type": "http", "port": 10102});

//normal
seneca.add({cmd: 'salestax'}, function (msg, done) {
  seneca.act({cmd: 'config', prop: 'rate'}, function (err, result) {
    var rate  = parseFloat(result.value)
    var total = msg.net * (1 + rate)
    done(null, {total: total})
  })
})
.listen({"type": "http", "port": 10103});

client.js

require('seneca')()
  .client( {port: 10101} )
  .client( {port: 10102} )
  .client( {port: 10103} )

  .ready( function () {
      this.act('cmd:salestax,net:100,country:IE,category:reduced', function (err, result) {
        console.log('IE: ' + result.total)
      })
      this.act('cmd:salestax,net:100,country:US,state:NY', function (err, result) {
        console.log('US,NY: ' + result.total)
      })
      this.act('cmd:salestax,net:100,country:DE', function (err, result) {
        console.log('DE: ' + result.total)
      })
      this.act('cmd:salestax,net:100', function (err, result) {
        console.log(result.total)
      })
  })
0 Answers
Related