Creating, managing and propagating errors in sync and async scenarios.

This story was originally published here.

Building robust Node.js applications requires dealing with errors in proper way. Error handling in Node.js is an opinionated topic. This is the first article of a series. It aims to give an overview of different kind of errors in Node.js and the creation and throwing of errors.

Handling Errors in Node.js:

  • Overview of errors in Node.js (this article)
  • Handling errors in Node.js (future)

There are basically two groups:

  • Operational Errors
  • Developer Errors

Operational Errors are errors that happen while a program is working on a task, like a network failure. Handling of operational errors…


How to convert callback to promise-based functions.

This story was originally published here.

Promises allow to handle the results of asynchronous code, like callbacks. Though, unlike callbacks, the async code with promises is easier to read, maintain, and reason about. They make writing asynchronous code easier and are an improvement to the callback pattern. If you want to see for yourself, feel free to search for callback hell in your favorite search engine.

Learn more about Promises in the article Understanding Promises in Node.js.

Node.js has a built-in util package. This util package includes utility functions. One of these is the promisfy() function that converts callback-based to…


Create the third phase for an ETL pipeline in Node.

This story was originally published here.

ETL is a process of extracting, transforming, and loading data from one or multiple sources into a destination. Have a look at the article ETL pipeline explained for a general overview on ETL pipelines.

This is the third article of a series of three articles, and it tries to explain the load phase in an ETL pipeline.

The third phase in an ETL pipeline is to Load the transformed data to the destination. After extracting the data from source and transforming it in the format we want, we…


Create the second phase for an ETL pipeline in Node.

This story was originally published here.

ETL is a process of extracting, transforming, and loading data from one or multiple sources into a destination. Have a look at the article ETL pipeline explained for a general overview on ETL pipelines.

This is the second article of a series of three articles, and it tries to explain the transform phase in an ETL pipeline.

The second phase in an ETL pipeline is to Transform the extracted data. The data can be completely reformatted in this phase, like renaming fields, adding new fields, filter data out…


Create the first step for an ETL pipeline in Node.

This story was originally published here.

ETL is a process of extracting, transforming, and loading data from one or multiple sources into a destination. Have a look at the article ETL pipeline explained for a general overview on ETL pipelines.

This is the first article of a series about ETL pipelines.

  • Extract (this article)
  • Transform
  • Load

The first step in an ETL pipeline is to Extract the data, which we are going to Transform and Load in future steps. In the extract phase the decision is, which data sources to extract from and how exactly (API, authorization, DB, …).

In…


Create and consume event emitters

This story was originally published here.

On the frontend-side of an application the user interactions are handled through events, click events, keyboard events, mouse moving events, etc. In Node.js (backend-side) we can build a similar system using the events module.

Much of the Node.js core API is built around event-driven architecture. There objects or emitters emit events that cause a function object or listener to be called. For example, HTTP and TCP servers are an event emitter, a TCP socket is an event emitter, HTTP request and response objects are event emitters.

All objects that emit events are instances of…


Use SSL in your local development environment

This story was originally published here.

If you’re running your Node.js backend locally its served using HTTP by default. In some cases it is required that your backend is served via https for integrating a service like Azure B2C or similar. This article is about how to configure express.js to serve a Node.js backend over https in local development. Let’s see how this can be achieved in Node.js.

If you want to find out how this is achieved in a React app, check out this article — How to setup ssl in React, for Angular check out this article —…


How to use async/await with Promises in Node

This story was originally published here.

Async/Await can be used to write asynchronous code in Node.js that reads like synchronous code and is available in Node since v.7.6 and up (officially rolled out with Node v8 and ECMAScript 2017). Any code that uses Promises can be converted to use async/await. For an overview of promises in Node.js have a look at the article: Promises in Node.js

The basic idea behind async/await is to write async code that behaves similarly to synchronous code, it should execute in the order it was written.

Let’s look at an example to compare code execution…


Understand what an API proxy is and the benefits of using it.

This story was originally published here.

In general, a proxy is something that acts as an agent or intermediary for something else. An API proxy provides an interface to developers for accessing backend services and sits between the application and the backend.

An API proxy acts as a handler between a consumer and backend services. It is a shim (layer of code, which provides compatibility between different interfaces), which handles data transformations, security, routing, and more. It exposes an interface customized for the consumer (web, mobile,…), makes the API calls to the different backend services on behalf of the consumer.


3 ways to make HTTP requests in Node.js

This story was originally published here.

Making HTTP requests is a core functionality for modern language and a daily task for a developer. One task you’ll encounter often in Node.js is making HTTP requests to an external API from a server.

Let’s take a look at three options on how to make an HTTP request, there are many more available.

The default HTTP module is the built-in way to make HTTP requests in Node.js. The module can just be required without installing it, which is a big benefit if you don’t want to add more dependencies to your project.

The…

Mario Kandut

Software Engineer skilled in React, Redux and Node.js with Expertise in Digital Marketing

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