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 

Get Mastering Node.js - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.