Latest in Servers and APIs

HomeServers and APIs

Building servers and APIs in Node.js — HTTP handling, routing, request lifecycles, and the patterns that keep backends maintainable.

Run your Node.js app on Apple's container (a Docker Desktop alternative)

Apple shipped container 1.0 — an open-source, native CLI that runs Linux containers on macOS by giving each one its own lightweight micro-VM. It speaks OCI images and has a Docker-like CLI. Here's a real Node.js app built and run on it, the networking model, x86 images via Rosetta, and the gotchas — all verified on container 1.0.0 on an Apple-silicon Mac.

Node.js Docker images: full vs slim vs alpine vs distroless

Which base image should a Node.js app use? The choice swings your image from ~1.8 GB down to ~210 MB and changes how you debug and secure it. Here are the real sizes for the same app on node:26, node:26-slim, node:26-alpine, and distroless — all measured with Docker — plus the tradeoffs that actually matter.

Ship a Node.js app as a single executable binary

Node.js can bundle your script and the runtime into one executable file — a Single Executable Application — so users run your CLI without installing Node at all. Here's the full build, an embedded asset, and proof the binary runs on a machine with no Node installed. Verified on real Docker images.

The built-in Node.js test runner: a complete guide

You no longer need Jest, Mocha, or Vitest to test a Node.js project. node:test ships a complete runner — suites, hooks, mocking, filtering, watch mode, and coverage — that you run with node --test. No dependencies, no config. Every command and its output here is from a real node:26-slim Docker image.

node:sqlite: a built-in SQL database with zero dependencies

Need a database for a script, CLI, or small service? Node.js ships node:sqlite — a synchronous SQLite driver built right in. No better-sqlite3, no node-gyp, no native compile, no npm install. Here's the full API — prepared statements, transactions, and user-defined functions — verified on a real node:26-slim image.

Running TypeScript natively in Node.js: 22 vs 24 vs 26

Node.js runs .ts files directly — no ts-node, no tsx, no build step. But the details differ between Node 22, 24, and 26: what's flagged, what's stable, and one feature that was removed in Node 26. Every example here was run on real node:22-slim, node:24-slim, and node:26-slim Docker images.

Node.js features that replace popular npm packages

Node.js has quietly absorbed the jobs that used to need dependencies: a test runner, a file watcher, a .env loader, native TypeScript, fetch, terminal colors, deep clone, even SQLite. Here's what you can drop on Node.js 26 — every example verified on a real node:26 Docker image.

The HTTP QUERY method: GET semantics with a request body

The new HTTP QUERY method (RFC 10008, 2026) gives you the safe, idempotent, cacheable semantics of GET with the request body of POST — ideal for large or structured read operations. Here's its status, browser and server support, and a form + fetch + Node example you can actually test.

View summary of all Docker containers memory usage

You can get pretty much all resource usage information with docker stats, but what you will lack there is the summary.
However, with some command line magic you can get the summary. You can put this in a .sh script, and make it executable with chmod +x docker-memory.sh:
mem_amount_total_with_unit=$(docker system info \ | grep 'Total Memory: ' \ | tr -d 'Total Memory: ') unit=$(echo ${mem_amount_total_with_unit} \ | sed 's/[0-9\.]*//g') mem_amount_total=$(echo ${mem_amount_total_with_unit} \ | sed...

Simple load balancer with Docker, Nginx and Node.js

It is a common knowledge that Node.js is a single-threaded single-core process. It sounds like an issue, but it gives you full freedom over how many processes you can run and how many cores want to utilize.
There are several ways you can scale Node over whole machine: run multiple processes, use Node to run subprocesses, or use virtualization software. We will focus on the latter, and see how we can also load-balance requests between all of them with a quiet primitive Nginx configuration.
...

Detect user country by IP in Node.js

It shouldn't be hard to detect a user's country based on the IP address, right? Right... I really liked the simplicity of ip2location module: load the BIN file, get the location, and close the BIN file.
Prerequisites Before you install the module, you will need to download the BIN file by registering at ip2location and choosing the appropriate option. You will have a choice between the country, country + city, or other options....

Push instant updates with EventSource API

EventSource is a handy API supported by all browsers, which runs over the regular HTTP protocol and doesn't require setting up a separate WebSocket service. However, it has limitations, such as data being one-directional (server to client) or a connection being constantly occupied. Let's dive in.
The server We will start with setting up a simple server using one of the ways from the previous article. After you have the server, we will set up a separate...

About Code with Node.js

This is a personal blog and reference point of a Node.js developer.

I write and explain how different Node and JavaScript aspects work, as well as research popular and cool packages, and of course fail time to time.