NodeJS security practices
NodeJS security practices Use strict mode Do not use loose comparison == Verify types of untrusted data types Use cryptography Add 2-factor methods
Free Online Tutorial For Programmers, Contains a Solution For Question in Programming. Quizzes and Practice / Company / Test interview Questions.
The list of most popular programming languages
NodeJS security practices Use strict mode Do not use loose comparison == Verify types of untrusted data types Use cryptography Add 2-factor methods
Assert module in nodeJS Introduction The assert module provides a set of assertion functions for verifying invariants We will learn the most used assertion functions Common assertion functions assert.deepEqual() assert.equal() assert.notDeepEqual() assert.notEqual() assert.deepEqual() Tests for deep equality between the actual and expected parameters Comparison details Primitive values are compared with…
Events in NodeJS Introduction Node.js is an asynchronous event-driven architecture All objects that emit events are instances of the EventEmitter class Event names are camel-cased strings When the EventEmitter object emits an event, functions attached to that specific event are called synchronously Implement event eventEmitter.on() method is used to register…
Process object in nodeJS Introduction It is a global object It provides information about and control over the current NodeJS process It is always available to Node.js applications without using require() because its a global object Process events The process object is an instance of EventEmitter beforeExit disconnect exit message…
Global Objects in nodeJS Basics Global Objects These objects are available in all modules The following variables may appear to be global but are not They exist only in the scope of modules __dirname __filename exports module require()
Stream module in nodeJS Introduction A stream is an abstract interface for working with streaming data in Node.js The stream module provides an API for implementing the stream interface There are many stream objects provided by Node.js For instance, a request to an HTTP server and process.stdout are both stream…
Path module in nodeJS The path module provides utilities for working with file and directory paths console.log(path.posix.basename('/os.js')); console.log(path.dirname('/os.js')); console.log(path.extname('os.js')); console.log(path.isAbsolute('os.js')); console.log(path.normalize('os.js/..')); console.log(path.parse('os.js')); // os.js // / // .js // false // . // { root: '', dir: '', base: 'os.js', ext: '.js', name: 'os' }
OS info in nodeJS The os module provides operating system-related utility methods and properties const os = require('os'); const os = require('os'); console.log(os.type()); console.log(os.release()); console.log(os.platform()); console.log(os.hostname()); console.log(os.version()); // Darwin // 20.2.0 // darwin // Darwin Kernel Version 20.2.0
File system in nodeJS Introduction The fs module enables interacting with the file system in a way modelled on standard POSIX functions To use the promise-based APIs To use the callback and sync APIs All file system operations have synchronous, callback, and promise-based forms // Using ESM Module syntax: import…
DNS in nodeJS Introduction Domain Name System (DNS) The DNS module enables name resolution. For example, use it to look up IP addresses of hostnames Uses the DNS protocol for lookups dns.lookup() uses the operating system facilities to perform name resolution const dns = require('dns'); dns.lookup('domainname', (err, address, family) =>…