Sign in

Thinker | Problem Solver | Travel Fanatic

Manage your node processes like your server, background workers and cron jobs with pm2 processes manager in production.

Don’t run node directly in production

Before we even discuss about PM2. We need to understand why we should not run node.js directly in production, what are the problems it causes and how can pm2 help us solve them?

Why not?

⦿ Your app will not restart if it breaks for some reason like too much load or some bug.
⦿ You can’t schedule processes, you’ll have to manually manage all the processes like your workers and cron jobs. …


Node.js tips and tricks to deliver more secure and robust applications.

Audit your 3rd party packages for vulnerability

You should use tools like npm audit or snyk to check for vulnerable dependencies. You can also use dependabot to keep yourself updated.

Use background jobs & queuing systems

You should use a Task Queuing System for performing heavy computation
tasks in the background. I’ll recommend you to check the Bull or Kue package.

Do not use anonymous functions

You should name all the functions, closures and callbacks. This will help
you easily understand what you are looking for from memory snapshots
while profiling your application.

Use a static type checker like Typescript

Static type checker will empower you to find certain problems even before your code…


1. What is the purpose of JSON stringify?

When sending data to a web server, the data has to be in a string format.

var userJSON = {'name': 'John', age: 31}
var userString = JSON.stringify(user);
console. log(userString); //"{"name":"John","age":31}"

2. What are closures?

It is an inner function that has access to the outer or enclosing function’s variables.

function Welcome(name){
var greetingInfo = function(message){
console.log(message+' '+name);
}
return greetingInfo;
}
var myFunction = Welcome('John');
myFunction(‘Welcome '); //Output: Welcome John
myFunction(‘Hello Mr.'); //Output: Hello Mr. John

3. Difference between let and var?

The main difference is the scope difference, while let can be only available inside the scope it’s declared, like in for loop, var can be accessed outside the…


This will not only be beneficial to you but also to the other developers that have to take a look at your code. So you’re not just doing this for yourself — you’re also doing your team a huge favor. So, here are the five common coding mistakes you should avoid as a developer.

1. Too many things going on in the same function

A function should only be responsible for doing one thing. The reason it is important to keep a function focused on a single concern is that it makes it more robust. I’ve seen way too many functions that fetch, process, and present data all in one…


What is Live Server?

Live Server is VS Code Extension used to launch a local development server with live reload feature for static & dynamic pages.


Axios is a promise-based JavaScript library, which gives you the ability to take advantage of JavaScript’s async and await for more readable asynchronous code. It can be used in both browser and Node.js to make HTTP requests.

Browser support

Axios is compatible with most of the modern browsers. And for those who are curious, it also supports Internet Explorer. This is where fetch lags. For more information on browser support you can refer to can I use the website.


The Fetch API is a simple interface for fetching resources. Fetch makes it easier to make web requests and handle responses than with the older XMLHttpRequest, which often requires additional logic. It is the new native JavaScript API, that allows you to make async requests similar to XMLHttpRequest and uses Promises.

This is a really simple fetch example —

fetch(url)
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.log("Error:", err.message));

We can also pass some options after the URL, such as methods, headers, body. If the options are not available, it would be just a simple GET request.

Comparing this…


What is Bottle?

Bottle is a fast and simple micro-framework for small web applications. It offers request dispatching (Routes) with URL parameter support, templates, a built-in HTTP Server and adapters for many third party WSGI/HTTP-server and template engines — all in a single file and with no dependencies other than the Python Standard Library.

Some of the features it provides —

  • Routing: Requests to function-call mapping with support for clean and dynamic URLs.
  • Templates: Fast and pythonic built-in template engine and support for mako, jinja2 and cheetah templates.
  • Utilities: Convenient access to form data, file uploads, cookies, headers and other HTTP-related metadata.
  • Server


Makes you faster and more focused

Taking part in programming contests make you a more disciplined, swift, and focused coder. In the competition, you must solve problems in a stressful situation and against time limit otherwise, you lose. Taking part in competitive programming teaches you how to be more focused on the task and not only complete it quickly, but accurately.

Helps you solve complicated problems

During the contest, you must solve difficult problems, which are not for ordinary programmers. While you are competing, you learn how to think out of the box. …


1. Easy to Learn

Python language is incredibly easy to use and learn for new beginners and newcomers. The python language is one of the most accessible programming languages available. There are a ton of resources available to learn python out there.

2. Efficiency

Python represents a different programming paradigm than older languages such as Java and C++. However, this “Pythonic” way of doing things often permits developers to get more done with less work–often in just a few lines of code.

3. Python is versatile for web development

Python is highly versatile and this extends to the web as well. When setting up a web server, you might think of Node.js, .NET…

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store