O'Reilly logo

Mastering Node.js - Second Edition by Kevin Faaborg, Sandro Pasquali

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Microservices with Seneca

Seneca is a Node-based microservice construction kit that helps you organize your code into distinct actions triggered by patterns. Seneca applications are composed of services that can accept JSON messages and optionally return some JSON. Services register an interest in messages with certain characteristics. For example, a service might run whenever a JSON message displaying the { cmd: "doSomething" } pattern is broadcast.

To start, let’s create a service that responds to three patterns, one pattern returning “Hello!”, and the other two different ways of saying “Goodbye!”.

Create a hellogoodbye.js file containing the following code:

// hellogoodbye.jsconst seneca = require('seneca')({ log: 'silent' });const 

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required