Learn how to build a REST API with the Express.js framework using Node.js and MySQL to easily write a new microservice.

In this tutorial, we will see how we can build a REST API with MySQL as the database and Node.js as our language. To make our task easier, we will use the Express.js framework.

Node.js is generally coupled with MongoDB and other NoSQL databases, but it performs well with relational databases like MySQL, too. In case you want to write a new microservice with Node.js for an existing database, it’s highly likely that the existing database will be the world’s most popular open-source database, MySQL.

Let’s get cracking!

Prerequisites

Below are some assumptions we are making before we get into the code:

  1. You have a good understanding of how MySQL and relational databases work in general.
  2. You have basic knowledge of Node.js and some understanding of the Express.js framework.
  3. You are aware of what REST (representational state transfer) APIs are and how they generally function.
  4. You know what CRUD (create, read, update, delete) is and how it relates to the HTTP methods GET, POST, PUT, and DELETE.

All the code will be done on a Mac with Node 14 LTS installed. If you want, you can try to use Node.js and Docker and docker-compose for a better developer experience.

#node #express #mysql #api #javascript

Node.js, Express.js, and MySQL: A step-by-step REST API Example
5.85 GEEK