As more companies invest in a cloud native infrastructure, they're choosing to prioritize their applications as microservices—architecting them into distinct servers. Each component is responsible for one (and only one) feature.
For example, you might have Server A responsible for handling billing logic, Server B for handling user interaction and Server C for handling third-party user interactions. These servers individually are microservices that make up the entirety of your application.
When designing a microservices architecture, you'll need to determine how these servers ought to communicate early on. For example, Server C might need to check billing information before performing some action, which means Server C would need to ask Server A if a user has the appropriate permissions.
We'll need an API to handle the requests and responses consistently in these cases. The most popular API protocols boil down to three choices: gRPC, graphQL and good ol' REST. REST is the lingua franca of the web; it has all the HTTP verbs you're aware of, like GET and POST, and matches very closely with how browsers send and receive data.
In this post, we will explore how to build a REST API and test it using Insomnia, an open source client for interacting with APIs. We'll build a simple server in Node.js and send requests to fetch and manipulate data. We'll also add different authentication strategies and show off some of the highlights of using Insomnia.
Getting Started
Before following this guide, be sure to install the latest version of Insomnia. You will also need to install the latest version of Node (at least version 14.0) and npm (which comes with Node).