Now that we have built the /register-and-broadcast-node endpoint, it's time we move on to some things that are a little less complex. In this section, let's begin building the register-node endpoint. This is going to be very straightforward compared to the endpoint that we built in the previous section.
This register-node endpoint is where every node in the network is going to receive the broadcast that is sent out by our register-and-broadcast-node endpoint. The only thing that this register-node endpoint has to do is register the new node with the node that receives the request for it.
To begin building the register-node endpoint, follow these steps:
- The first thing that we'll have to do is define the newNodeUrl; therefore, add the following highlighted line of code:
// register a node with the network
app.post('...