January 2018
Intermediate to advanced
332 pages
7h 36m
English
Now that we have the server up and running, we can create an in-memory chat endpoint, which would accept a message from two users and forward it to its intended recipient using a queue while retaining the order.
Before we add the logic, we will need to do some groundwork to set up the application in a modular way. First, let's include the body-parser and use it in an express middleware so that we can access the body of requests easily. So, the updated index.js file looks as follows:
var express = require('express');var app = express();var bodyParser = require('body-parser');app.use(bodyParser.json());app.use(bodyParser.urlencoded({ extended: true }));app.get('/', function (req, res) { res.status(200).send('OK!')
Read now
Unlock full access