How to do it...

Our service is going to record events of interest in the system such as page loads. In a full system we might record this type of information against specific user ID's in order to analyze system usage patterns. However, since our basic system doesn't include user context we will simply be recording events as system events.

Let's start by creating a directory for our service and initializing it with a package.json, then install the redis, mongodb, and concordant modules, as follows:

$ cd micro$ mkdir eventservice$ cd eventservice$ npm init -y$ npm install --save redis mongodb concordant

Next we'll create the now familiar service structure within our micro/eventservice folder:

$ touch index.js wiring.js service.js 

Our usual ...

Get Node Cookbook - Third 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.