Every developer sooner or later faces a problem on how to deal with cron jobs. The list of cron jobs use-cases is enormous: cache invalidation, reports generation, refreshing data from external sources, notifications, backups etc. And of course my favourite one: restarting services with memory leak every night :) Today we’ll walk through several scheduled tasks implementations from development and infrastructure perspectives.

Historically Cron jobs have a special format for schedule definition https://en.wikipedia.org/wiki/Cron. I find it kinda funny that we’re still using the format developed in the 70’s, it’s not intuitive at all. But don’t be afraid of it, there’re…


As you may know Node.js really sucks with heavy CPU-intensive operations, because of its asynchronous architecture, but sometimes we need to somehow deal with them without slowing down the entire service. And today we’ll talk about how to split the load of your app into background jobs.

Let’s assume we’re developing some SaaS application and we need to generate an invoice for a new customer. Generation of PDF is a long and CPU-intensive operation, if it’s performed right in the controller, you’ll loose the control of CPU loading and some russian hacker can easily DDoS your app. Also if you…


Even well-experienced developers need to refresh their knowledge before an interview. Of course, every interviewer has his own questionnaire, but there are a lot of common questions. In this article, I’ve prepared a list of popular questions about Node.js. Let’s start!

Node.js

First section is about Node.js itself, not about JavaScript. Unfortunately a lot of people don’t understand the difference.

What is Node.js?

https://en.wikipedia.org/wiki/Node.js. Node.js is not a programming language, it’s runtime environment to run JavaScript. It uses Google’s V8 engine, same engine is used in Google Chrome. But V8 is not a part of Node.js, it’s a separate component. Microsoft…


Do you use Docker? I bet you do! These days Docker is a very common thing and almost every vacancy has the requirement to have experience with Docker. Usually, developers write a service and create Dockerfile for it and then pass it to the DevOps team to create a CI/CD pipeline to deploy it to production and other environments. But what about local development? Can Docker be useful on my laptop? Of course, it can. In this article, we’ll walk through the basic use cases of Docker in the local development process.

Environment

Back in 2015 PostgreSQL, MySQL, MongoDB, Redis…


Hi there! Today we’ll talk about a very common, but very important part of every project: configuration. Of course, its implementation depends on programming language, framework, and infrastructure, but the principles and the requirements of configuration mechanism are the same everywhere. I won’t talk about what configuration is, the main focus of this article is to show the approaches to how to properly set up configuration mechanisms with some examples for Node.js backend service deployed in Kubernetes.

Step 1. Start using configuration

Obvious step. But even if you’ve already added config to your projest, take a fresh look on your…


Hi there! Here comes the ending episode of the TypeScript Builtin Types trilogy. But first of all let me explain what these articles are about and why I’m writing them, better later than never. The main purpose of this series is not just to tell you about TypeScript features and how to use them. It’s about understanding the power of the dark side!

Just kidding, it’s about how do they actually work under the hood. This knowledge provides you the full picture of TypeScript language, it’s the foundation which will help you to solve any tricky task. And of course…


Here we go again! In my previous article, we looked through Partial<T>, Required<T>, Readonly<T> and Pick<T, K> types and today we continue to strengthen our arsenal with new tools.

Let’s start! The first one is Record<K, T>:

K extends keyof any actually means that K can be string, number or symbol and [P in K]: T means that every property should be T.

I remember the first time I faced Record<T, K>, I had defined one variable as object and received eslint error:

Of course I could disable this rule, but I decided to figure out why object


Hey all. Today we’ll talk about some useful TypeScript bultin types, that can significantly simplify your code and perform some type magic.

Let’s start with well-known type Partial<T>:

We can use Partial<T> for objects with all properties list of T or only with some of them. An empty object {} can be used as Partial<T> as well. But we are not able to pass objects with properties which don’t exist in T.

Partial<T> is a very useful tool, we can use it for database update queries or in httpPATCH method bodies, when we don’t the whole set of object…


Hello again! In my previous article we discussed TypeScript property decorators and today we continue with method decorators. We will sort out what they are and how to use it with some practical examples.

According to official documentation: “A Method Decorator is declared just before a method declaration. The decorator is applied to the Property Descriptor for the method, and can be used to observe, modify, or replace a method definition.”. Let’s have a look at MethodDecorator typing declared in TypeScript:

It’s a function which receives params target (a class instance with decorated method), propertyKey(name of the decorated method)…


Most everyone knows what TypeScript decorators are, there are tons of articles about this topic. I won’t spend your time describing what they are and why you should use them (or not). In this article we’ll talk about some advanced TypeScript decorators practices. If you don’t familiar with TypeScript decorators, please take look at official documentation first.

Let’s start with property decorators. Here is the type definition of PropertyDecorator from TypeScript lib.

Property decorator is just a function which receives object which contains property and property’s key.

Let’s write a simple property decorator which performs some logging.

This…

Alex Vasilyev

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