NodeJS Get HostName from request ExpressJS

Sometimes we need hostname to do various log activities. We can get the hostname from the request property in ExpressJS NodeJS. We have two options to get the hostname: hostname property of request header method of request Request HostName Property Below code is shown to get hostname from request object. app.get('/',(req, res) => { hostName = req.hostname; //dotnetpattern.com...

Continue Reading

NodeJS UUID Validate

To validate UUID (GUID) in NodeJS, we can use below options: UUID NPM Package We can write our own custom regular expressions to validate. 1. UUID NPM Package To use UUID package, we can use below command to include in our project. To validate UUID in NodeJS, we can use validate method of UUID package. Below is the sample code. const uuid = require('uuid'); const uniqueId = "3112b3db...

Continue Reading