
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 266 Articles for Node.js

96 Views
The dns.resolveSoa() method uses the DNS protocol to resolve the start of authority records for the hostname. The address argument passed to the callback function will be an object that will contain the following properties −nsnamehostmasterserialrefreshentryexpireSyntaxdns.resolveSoa(hostname, callback)ParametersIt accepts the following parameters −hostname – This parameter takes the input for the hostname to be resolved.callback – This function will catch errors, if any.records – Returns the start of authority records for the hostname.ExampleCreate a file with the name "resolveSoa.js" and copy the following code snippet. After creating the file, use the command node "resolveSoa.js" to run this code as shown in ... Read More

11K+ Views
We can download file using Node.js by either using third-party libraries or using some inbuilt packages.Method 1: Using 'https' and 'fs' moduleWe can use the http GET method to fetch the files that are to be downloaded.The createWriteStream() method from fs module creates a writable stream and receives the argument with the location of the file where it needs to be saved.pipe() is another method from fs that reads the data from the readable stream and writes it onto the writable stream and file.Example 1Create a file with the name downloadFile.js and copy the following code snippet. After creating the ... Read More

239 Views
The diffieHellman.computeSecret() is used for computing the shared secret using the public key of other's party and returning the computed shared secret. The suppliedKey is interpreted using the specified inputEncoding and the secret is encoded using the specified outputEncoding. If the inputEncoding is not specified the other publicKey is expected to be a buffer, DataView.SyntaxdiffieHellman.computeSecret(otherPublicKey, [inputEncoding], [outputEncoding])ParametersotherPublicKey – This is the public key that is used to compute the secret.inputEncoding – This encoding is used to interpret the supplied key.outputEncoding – This encoding is used for encoding the computed secret value.Example 1Create a file with the name "computeSecret.js" and copy ... Read More

456 Views
A timer can only be cancelled after it is being scheduled. The Immediate class has an object for setImmediate() method and passes the same object to clearImmediate(), in case it wants to cancel the scheduled timer function.Scheduling TimersThis type of timers schedules the task to take place after a certain instant of time.setImmediate()setInterval()setTimeout()Cancelling TimersThis type of timers cancels the scheduled tasks which is set to take place.ClearImmediate()clearInterval()clearTimeout()1. clearImmediate() methodThis method clears the Immediate timer object that is created by the setImmediate() method.SyntaxclearImmediate( timer )Examplefilename - clearImmediate.js// clearImmediate() Example var timer = setImmediate(function A() { console.log("Timer set"); }); ... Read More

6K+ Views
In this article, we will see how to integrate Redis Cache with Spring Boot. We will learn how we can configure Redis data inside the Spring boot cache.Let's look at the dependencies first that are required to import Redis into a Spring boot application.Dependencies// Adding spring-boot cache & redis dependencies org.springframework.boot spring-boot-starter-cache 2.4.3 org.springframework.boot spring-boot-starter-data-redis 2.4.3 ConfigurationAfter adding the Redis dependencies, you now need to perform some configuration so that it could be used in your project. Spring Boot will automatically configure a Redis-cache Manager but with default properties. We can ... Read More

215 Views
The dns.lookupService() method resolves a given address and port into a hostname and service. This method uses the operating system's underlying getnameinfo implementation. A TypeError will be thrown if the address is not a valid IP address.Syntaxdns.lookupService(address, port, callback)Parametersaddress - This parameter takes input for the IP address that needs to be resolved.port - This parameter takes input for the port number that is attached with the IP address.callback - It will catch errors, if any.Example 1Create a file with the name "lookupService.js" and copy the following code. After creating the file, use the command "node lookupService.js" to run this ... Read More

124 Views
The diffieHellman.setPrivateKey() sets the Diffie-Hellman generated private key. The private key will be a string if an encoding argument is provided. If no encoding is provided, the private key will be of type buffer.SyntaxdiffieHellman.setPrivateKey( privateKey, [encoding] )Parametersencoding - This parameter specifies the encoding of the private Key.Example 1Create a file with the name "privateKey.js" and copy the following code. After creating the file, use the command "node privateKey.js" to run this code as shown in the example below// diffieHellman.setPrivateKey() Demo Example // Importing the crypto module const crypto = require('crypto') // Generating the key pairs(public & private) crypto.generateKeyPair('rsa', ... Read More

362 Views
A 'warning' event is emitted whenever a Node.js event emits a process warning. The process warning is similar to an error that describes the exceptional conditions that are being brought to the user's attention.Node.js can emit warnings whenever it encounters any bad coding practices that could lead to poor performance or bugs.SyntaxEvent : 'warning'Example 1Create a file with the name "warning.js" and copy the following code. After creating the file, use the command "node warning.js" to run this code, as shown in the example below// Event: warning Demo Example // Importing the process module const process = require('process'); ... Read More

987 Views
The Timeout object is internally created and is returned from the setTimeout() and setInterval() methods. You can use this object and pass it to either clearTimeout() or clearInterval() if you want to cancel the scheduled actions.Following are the timeout class ref objects that can be used to control the default behaviour −1. timeout.ref()This method is called if the timeout object's event loop does not exist. The actual use of this method is only after the timeout.unref() is called, and you need to reference the timeout object again.Syntaxtimeout.ref()2. timeout.unref()This method will tell the timeout object that the Node.js event loop does not ... Read More

591 Views
Redis also supports the monitor command that lets the user to see all the commands received by the Redis server across all the client connections. These connections include commands from everywhere, including other client libraries and computers as well.The monitor event will monitor all the commands which are executed on the Redis server where monitor is enabled. The callback from the monitor receives the timestamp from the Redis server, an array of commands along with the raw monitoring string.Syntaxclient.monitor( function(callback) )Example 1Create a file with the name "monitor.js" and copy the following code. After creating the file, use the command "node ... Read More