Node.js: Setup Different Configuration Settings for Development & Production Server

This article shows how you can set up different configuration files for different servers like a production server or development server. For example, we can have different database configuration settings for development server and production server. If we write the database config settings (hostname, username, password) in the single file then we have to manually … Read more

Node.js: Include another JS, ENV, JSON file in the app

This article shows how you can include another JS (Javascript) file into your main application JS file. We can have a situation where we store configuration settings or database settings in another file. It can be .js, .env, .json or any other file. We will be using module.exports object to achieve this. I have created … Read more

Node.js: Using Async/Await Function to Avoid Promise Chaining & Callback Hell

This article shows how you can use Async/Await function instead of Callback functions or Promise while writing the synchronous programming code in Node.js. Node.js is asynchronous/non-blocking in nature. If we want to execute certain code only after the execution of another code then we can use Callback functions. However, there can be a need of … Read more

Node.js: Using Promise to Avoid Callback Hell

This article shows how you can use Promise instead of Callback functions while writing the synchronous programming code in Node.js. Node.js is asynchronous/non-blocking in nature. If we want to execute certain code only after the execution of another code then we can use Callback functions. However, there can be a need of using nested callback … Read more

Node.js: Using Callback Functions for Synchronous Programming

Node.js code is asynchronous in nature. This article shows how you can use callback function in Node.js for synchronous programming. I have written an article with examples on synchronous and asynchronous programming in Node.js. Here’s the link: Node.js: Asynchronous & Synchronous Code Programming In the callback method, you simply pass a function as a parameter … Read more

Node.js: Asynchronous & Synchronous Code Programming

Node.js is asynchronous in nature. The Node.js APIs are asynchronous or non-blocking. The long-running operations/APIs in Node.js are non-blocking. In Node.js: – The server never waits for any operation to complete and return the data. – The server moves to the next API/operation after calling it. – The response of the previous API call is … Read more

Node.js: Pass Arguments/Parameters to Programs in Command Line

This article shows how you can pass command line arguments/parameters to any Node.js programs or .js file. Here’s an example: node index.js This will execute the index.js file program. Suppose, you can to pass some arguments and values to the index.js file program via command line. For example, in the below command, we are trying … Read more

Base64 encode/decode in Nodejs and Javascript

This article shows how you can base64 encode and decode string using both Nodejs and Javascript. Javascript: Base64 encode/decode string Encode String btoa() function creates a base-64 encoded ASCII string from the given String object. var encodedData = window.btoa("Hello World!"); console.log(encodedData); // output: SGVsbG8gV29ybGQh Decode String atob() function decoded the base-64 encoded string. var encodedData … Read more

Node.js, MongoDB & Express: Simple Add, Edit, Delete, View (CRUD)

This article shows how you can create a simple CRUD (Create, Read, Update, Delete) application in Node.js using MongoDB as database. We will also be using Express Framework to build this Node.js web application. Previously, I had written an article on Creating basic CRUD application using Node.js, Express & MySQL database. This article contains creating … Read more