Node.js server - REST Logger

Anywhere on your machine, create a folder named REST-Logger. In this folder, we are going to build the Node.js server application.

For this server, we need to have Node.js installed. You can visit https://nodejs.org/en/download/ to download the version of Node.js that is applicable for your machine.

Once Node.js is installed, we will go ahead. Open a new Command Prompt or terminal here and run:

npm init -y

Next, create a new file named server.js at the root of the REST-Logger folder and update it as shown:

var http = require('http');var server = http.createServer(function(req, res) {  var jsonString = '';  req.on('data', function(data) {    jsonString += data;  });  req.on('end', function() { var data = JSON.parse(jsonString); ...

Get Enterprise Internet of Things Handbook 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.