Build a complete CRUD application with Express JS



Reading time : 2.5 min
RESTful APIs has made its way through the developer community and finally a  reached stage where it has become an essential to survive as a Software Engineer . An API (Application Program Interface) consists of a set of functions or procedures that define how an application would consume or exchange data . A RESTful API follows the REST architecture which defines a set of rules on how web services can be used to exchange data in and out of web applications.

In this blog article I will be sharing my own experience in building up a REST API using Node JS and Express JS where MongoDB is used for data storage.

Before we begin with , make sure your PC has the following pre-requisites installed.
  • Node JS
  • Mongo DB Server
  • Postman or any other REST client 
  • An IDE 
To verify ,

  1. Open a terminal window and give the command Node -v and NPM -v if Node JS and the Node Package Manager are installed the output will be as follows  If Node is not installed , click https://nodejs.org/en/download/ to download the latest compatible version .
  2. Then let's verify MongoDB server installation by giving the Mongo -v  command in the terminal . If not head to https://www.mongodb.com/download-center/community

  3. Make a root directory to store the project files . I have called mine "RentACar" as I am on the process of making a REST API for a website that rents vehicles. Open that folder using an IDE and in the terminal of the IDE give the command NPM init  to run the wizard to initialize the Node project. You may accept the defaults or change the descriptions .

  4. Then expand the files in your root directory inside the IDE and you will see a package.json file has been created .
  5. With NPM , install Express JS by giving the command npm install express --save .  We give the --save flag to update the dependencies in the package.json file .
  6. Now create a index.js file in the same directory .






















Comments