Photo by Bartosz Kwitkowski on Unsplash.

Literal types in TypeScript allow for narrowing down the type to the exact value. You can communicate in the type system that the value has to be exactly this string not a string or one of those particular numbers and not just any number. Until TypeScript 4.1, we had three literal types: strings, numbers, and booleans. TypeScript 4.1 introduced the fourth literal type: template literal.

The goal of the article is to play with literal types to get to know them better.

This article has originally been published on my personal blog.

Basic Template Literal


Photo by Sincerely Media on Unsplash.

In September, I took two weeks off to enjoy some time in nature before the rainy autumn hits. Apart from the time for relaxation, the holiday for me is a good time to look back, draw conclusions, and plan something exciting that will keep my motivation afloat. I was looking for a book that will tap into my curiosity. Daniel Vassallo, who I follow on Twitter, tweeted about Philip Kiely’s book: Writing for Software Developers. That’s how I learned about the ebook and purchased it soon after.

This article has originally been published on my personal blog.

Writing for Software…


Photo by Thao Le Hoang on Unsplash.

When legacy code is giving you a hard time, it’s a good time to learn yourself a few new tricks. You might not think there’s a method to this chaos in your codebase, but there are a few. In this post, I share with you four proven methods of working on improving legacy code.

This article has originally been published on my personal blog.

I’ve prepared a repository with exercises you can do to put your newly acquired skills to the test after completing the article. I use it when conducting the workshop on working with legacy code.

Before starting…


Photo by JESHOOTS.COM on Unsplash

At the beginning of the project, everything is simple and easy. The entire codebase fits in the mental model you have in your head. Deployment, although not yet fully automated, doesn’t take you much time since the release cycle is simple, and there’s only a single environment often equal with the master branch. You may use this environment for your colleagues to explore the API, for QA engineer if you already have one, perhaps for your project manager, as the task’s DOD (definition of done) requires a deployment. …


Photo by Gabriel Wasylko on Unsplash

SFTP ( SSH File Transfer Protocol) allows for secure file transfer to and from the server. SFTP, despite its name, isn’t based on FTP, which, unlike SFTP, doesn’t allow for encrypted file transfer. FTPS is an extension of FTP that allows only to encrypt login and password. That’s the basics when it comes to the security aspect of the very protocol.

Additional considerations to secure our server are disallowing password authentication and replacing it with SSH key-based authentication. …


Photo by Brett Jordan on Unsplash.

I find myself reaching to previous projects for this function every time I need a random, unique value to use on the client-side. You might not have heard of the Web Crypto API which provides a set of low-level primitives for dealing with cryptography. For a rather unpopular API, Web Crypto API is well supported in modern browsers and IE 11.

// random.ts
function randomId(): string {
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
return uint32.toString(16);
}

There are multiple packages available that can fulfill a similar purpose, although this particular browser-native solution has a few advantages over packages like nanoid, shortid…


Photo by Maximilian Weisbecker on Unsplash.

Kubernetes (k8s) is a platform for deploying, scaling, and managing containers. Kubernetes may be daunting to pick up in the beginning, and you probably already found out about it the hard way. I learn the most by doing, and in this tutorial, I set up a Kubernetes cluster that is very close to something you would run on production.

The project consists of a frontend application, the backend that connects to Redis, which is accessible only from within the cluster. Both frontend and backend enforce HTTPS connection and have SSL certificates issued by Let’s Encrypt that automatically renew. Additionally, backend…


Photo by João Silas on Unsplash.

In production, the most important advantage of using a build tool like webpack is a smaller size and thus improved overall application performance. Although beneficial for our users, the bundled and minified code is harder to debug for developers as the code they have written doesn’t map 1:1 to error stack traces. Multiple tools for minifying, bundling and transpiring JavaScript modules can generate source maps along with the resulting code. Source maps allow developer tools (Chrome DevTools, test runners, error reporting software) to find a reverse mapping from the optimized code back to the source code.

Rollbar (and often other…


What’s io-ts? In theory, io-ts is a runtime type system for IO decoding/encoding. In practice, io-ts is an elegant solution to a very nasty problem.

Statically-typed applications that interact with the external world are facing a challenge to keep this interaction surface type safe. One of the most prominent is data input, especially working with requested data via REST or GraphQL endpoints but also structured text files, uploaded CSV and JSON files.

If you get stuck and would like to try a more gradual introduction or would like to read more about algebraic data structures, read my previous article Pattern…


Photo by David Kovalenko on Unsplash

Express is a microframework that according to the 2018 Node.js User Survey Report is used by 4 out of 5 back-end and full-stack node.js developers. Thanks to its simplicity, the always-growing range of available middleware, and an active community, the Express user base is still growing.

Arguably, the simplicity of Express is its most significant advantage, but it comes with the cost of a bare-bones API for handling requests, and leaves the rest to the developer. In general, it’s fantastic! We’re developers, and we love to roll out the solutions that we can tailor to meet our requirements.

The two…

Michał Załęcki

Senior Software Engineer at @Hotjar. I particularly enjoy TypeScript. I focus on unit testing, software design, and architecture.

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