Now that we have all the prerequisites set up, create an index.js file inside the root directory:
touch index.js
So far, we have created a lot of files and folders. Your sensor-project directory structure up until this point should look like this:
.
├── hello-world
│ └── hello-world.js
└── server
├── .gitignore
├── index.js
├── package.json
└── node_modules
└── ...
We are now going to write the code to run our server by editing the server/index.js file.
First, we have to import the express library we just installed:
const express = require('express');
The require function is a part of the node's standard library. It imports the module given as its argument and returns it. In this line, we are importing the express module and assigning it to the express variable.
We then create an instance of a server application:
const app = express()
The express variable is a constructor, which is a function or method that returns an object. In our case, the express constructor returns an instance of an express server application.