node.js: API COVID-19

1st step: Create a directory for the project and enter the same

mkdir apiCovid
cd apiCovid

2nd step: Start the project

npm init

3rd step: Install the required packages

npm install --save express body-parser mongoose

4th step: Create the index.js and the MVC files

touch index.js
touch covidController.js
touch covidModel.js
touch covidRoutes.js

5th step: Enter the page where you will find all the data about COVID-19 by clicking here

  1. Select the 2nd get: “/Requests/get_entry/{date_1}_until_{date_2}”;
  2. Click on the “try it out” button and then on date_1 set date 29–03–2021 and date_2 set date 4–4–2021 and finally, click on execute;
Date format

6th step: Open mongoDB Compass, connect to the database and create a database, filling in the following spaces

7th step: Enter the database you created, click “Add data”, then “import file”, select input file type “JSON” and go to “Browse” to find the JSON file you downloaded and “Import”

8th step: After importing, we will edit the database so that it looks like this

Final aspect of the Database

Now, it’s time to program our API

9th step: Open index.js and put the following code

So, let’s move on to the most important part of our API: the MVC

10th step: Open covidModel.js and put the following code

11th step: Open covidRoutes.js and put the following code

12th step: Open covidController.js and put the following code

Last Step: Open Postman and let’s put the following address: http://localhost:8888/api/covid/

I hope you have succeeded and that you have learned something!!

--

--

--

Finalist student in Computer Engineering

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

Creative Coding Midterm Assignment3

How to build a backend app with TypeScript, Node.js, and Express

How to create basic React application without create-react-app

Detecting System Dialogs with Detox E2E and React Native

JavaScript Exciting Features in 2020–2021

Deep Dive Into Tree-Shaking

Given an array of integers, find the length of the longest increasing subsequence.

How to fix wangEditor ‘error in mounted hook’

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Afonso Antunes

Afonso Antunes

Finalist student in Computer Engineering

More from Medium

Node Js For Web Development

How To Test a NodeJS Module using Mocha and Assert

Introduction Node.js