Defining the /register-and-broadcast-node endpoint

The first endpoint that we create will be /register-and-broadcast-node, and this is defined as follows: 

app.post('/register-and-broadcast-node', function (req, res) {});

The preceding endpoint will register a node and broadcast that node to the whole network. It will do this by passing the URL of the node we want to register on the req body. Therefore, type the following inside the preceding endpoint:

const newNodeUrl = req.body.newNodeUrl;

We're not going to build this endpoint now, but when we use it in later sections, we'll be sending in the URL of a new node that we want to add to our network. Then we're going to make some calculations and broadcast the node to the entire network so ...

Get Learn Blockchain Programming with JavaScript 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.