Google News
logo
NodeJS Interview Questions
Passport is a widely used middleware present in Node.js. It is primarily used for authentication, and it can easily fit into any Express.js-based web application.
 
With every application created, it will require unique authentication mechanisms. This is provided as single modules by using passport, and it becomes easy to assign strategies to applications based on requirements, thereby avoiding any sort of dependencies.
The DNS lookup method uses a web address for its parameter and returns the IPv4 or IPv6 record, correspondingly.
 
There are other parameters such as the options that are used to set the input as an integer or an object. If nothing is provided here, both IPv4 and IPv6 are considered. The third parameter is for the callback function.
 
The syntax is:
 
dns.lookup(address, options, callback)
Test pyramids are implemented by defining the HTML API. This is done using the following:
 
* A higher number of unit test cases
* A smaller number of integration test methods
* A fewer number of HTTP endpoint test cases
Assert is used to explicitly write test cases to verify the working of a piece of code. The following code snippet denotes the usage of assert:
var assert = require('assert');
function add(x, y) {
return x + y;
}
var result = add(3,5);
assert( result === 8, 'three summed with five is eight');