Setup the Node JS application

Code app.js

const express = require(“express”);

const app = express();

app.get(“”, (req, res) => {

res.send(“Hello Express”);

});

app.listen(3000, () => {

console.log(“Server is up on port 3000.”);

});

Run the command node src/app.js

How to set up nodemon?

Nodemon allows us to re-run the server if any modification made on code level no need again restart the server by node src/app.js

GitHub: https://github.com/msunil037/Webserver-NODEJS


Algorithm

Code(JavaScript)


Setup MongoDB

Initial Code:-

const mongodb = require(‘mongodb’);

const MongoClient = mongodb.MongoClient;

const connectionURL = ‘mongodb://127.0.0.1:27017’;

const databaseName = ‘test’;

MongoClient.connect(connectionURL, { useNewUrlParser : true }, (error, client) => {

if(error){return console.log(‘Unable to connect to database’);}

console.log(‘Connected Successfully!’);

const db…

Sunil Majhi

Full Stack Developer

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