Member-only story
Build a REST API with Node.js and Express.js

In this guide you can build a REST API with Node.js and Express.js. Then, in a next part, we will be building automated Unit tests using Mocha and Chai, ready for a Test-Driven Development (TDD).
The main components of this REST service are:
- A Node.js base project, created as a NPM module
- An Express.js web server to manage the API endpoints, requests and responses
- A SQLite database for application storage
Previous Requirements
If you haven’t installed Node.js, visit https://nodejs.org/es/download/ for download and installation instructions. Also, you may want to install a Git client to create a local repository for your code.
The Node.js base project
To start with a Node.js and Express.js project, create a new project folder. Then, create an empty NPM project, using the npm init
command :
mkdir node-express
cd node-express
npm init
The npm
command will ask some information about your project. Is not necessary to fill out every field. The most important are: package name, and entry point. Our entry point will be a file named server.js
(our Express.js API server)
package name: (express)…