How to create lightweight and performance Dockerfile especially for Node.js applications.

Image for post
Image for post
Photo by Victoire Joncheray on Unsplash

Hello World! Today I’m about to share my notes and thoughts about Dockerfile for Node.js applications. I hope you will find it useful and create Dockerfile, which will suit all your needs.

Docker Introduction

If you are here it means, that you have faced Docker before, but to be sure that we are on the same page let’s remind what it is.

So, there are no secrets — Dockerfile is an instruction of how our image will be built. Step by step, layer by layer this file describes how our image will look like.

Okay, so another question — what is an…


Improve the usage of browser APIs by adding a custom wrapper

Code on a laptop
Code on a laptop
Photo by Christopher Gower on Unsplash.

Today’s article will be useful for front-end developers who want their code to be type-safe and more readable. I would like to show you how you can wrap different browser APIs to have better control of the situation. For instance, I will use localStorage.

Quick Refresh

LocalStorage is browser storage that is used to store data across browser sessions. It isn’t a big deal to work with localStorage. It has a pretty simple interface:

OK, you may ask, “Why do we need any wrapper at all since it has such a simple interface?” …


Real-world use case of using singleton in TypeScript

Image for post
Image for post
Photo by Markus Spiske on Unsplash

Hello World! Today I’m gonna tell you about axios and singleton. As a basis, I’ll take my previous article on this topic. So, if you miss some part of the code, or something is unclear — please check the first part.

Introduction

From the previous article or from your background you may know that axios is one of the most popular libraries to make an HTTP request. It can be used both on a client and server side. It provides some tools to reduce the amount of code, make it clear and readable. One of such tools is axios.create to create…


Drop these in your codebase today

Image for post
Image for post
Photo by Vishal Jadhav on Unsplash

Hello World! Today I want to share with you my notes regarding React Hooks. I believe that since the 16.8 version of React, when Hooks were introduced, everyone has had a chance to get to know them. I also believe that this article will help you to get on really well with Hooks.

Before we start, I should note that I use TypeScript only because of my preferences, and if you want, you can use Hooks with plain JavaScript.

Each section will have:

  1. Ready code snippet
  2. Explanation
  3. Example of usage

Ok, let’s not waste any more time!

useInput

My suggestion is…


Use your medical benefits and be covered by your insurance at 100%

Image for post
Image for post
Photo by Kendal on Unsplash

Unless you are hiding under the rock, I am sure you’ve heard about COVID-19 and how much it influences our lives. It changed everything, starting from the way we clean our hands to health insurance policies.

Health is our top priority and now, as never before, it is necessary to take care of yourself and all your closest people. That is why, please, stay home unless you have an emergency or your toilet paper supply goes to the end.

Fortunately, health insurance companies in the USA help people with that.

Telehealth coverage

All major and small Health Insurance Providers responded to COVID-19…


Use OOP to make HTTP-request like a pro

Image for post
Image for post
Photo by Émile Perron on Unsplash

Hello, world! Let me share some tips on how to boost your regular axios-instance to something powerful.

Let’s cover some basics so we know that we are on the same page. In JavaScript/TypeScript, we can make HTTP requests whether we are talking about client-side or server-side.

For client-side, you can use old-school XMLHttpRequest (please don’t do that), or modern the fetch based on Promises.

For server-side, the Node.js module https is always available for you.

Nevertheless, most of us use libraries and one of the most popular is axios.

Axios Instance

The first step for achieving cleaner code is an instance of…


Use an absolute path in your projects instead of a relative one

Image for post
Image for post
Photo by Florian Olivo on Unsplash

Hello, world!

Today I want to share some tips with you to improve your projects and make it much easier to maintain. I’m talking about aliases.

Explanation

If you’ve never heard of aliases you’ll find this section useful.

According to the dictionary, an alias is a name that a person assumes for a particular purpose. We can give aliases to our files or even folders in our project. As usual, more information can be found in the documentation.

Aliases in Webpack

Assume we have a folder structure like this:


Resolve routine tasks in an unusual way

Image for post
Image for post
Photo by Fleur on Unsplash.

Have you ever tried to look at a string in JavaScript from a different angle? You know that we can convert it to an array, but it can actually behave like a real array.

Hello, world! Today I want to share with you some cool stuff that may help you in your work or at least to show off knowledge during an interview.

Routine Tasks

Our example will be pretty simple, but it will help you change your paradigm regarding this topic.

For instance, you may face a problem when you have to separate each letter in a word and maybe put…


Build a simple event emitter based on ES6 classes

Image for post
Image for post
Photo by Kevin Ku on Unsplash

What’s it For?

First of all, for your understanding and knowledge. To get the full picture of how something works, write it yourself.

Secondly, to write cleaner code. We’ll give you a real example.

Last but not least: you might be asked to write your own small and simple EventEmitter in an interview — it would be nice to be prepared!

Hello World!

Let’s start with the documentation. The Node.js documentation answers all the questions you may have but, like much documentation, it’s a bit complicated. That’s why you may want a quick guide.

Creating

As I mentioned, we’re going to use ES6 Classes.

Oleh Zaporozhets

Full Stack Developer

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