How to do it...

Let's begin by installing concordant (a DNS lookup module) into the webapp folder:

$ cd micro/webapp$ npm install --save concordant 

Let's include the newly installed concordant module into webapp/routes/audit.js. The top of webapp/routes/audit.js should look like so:

const { Router } = require('express')const restify = require('restify')const { dns } = require('concordant')()const router = Router()var client 

Notice how we also declared an (as yet) undefined client variable.

We're going to use an Express routing middleware pattern to split up the resolving of a DNS service, and the server response. Let's modify the GET route in webapp/routes/audit.js to:

router.get('/', resolve, respond) 

Our resolve function in webapp/routes/audit.js ...

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.