Skip to content
tezvyn:

Node.js

42 bites tagged Node.js — interview questions with model answers, and 60-second explainers.

Node.js & Express1 min read

What are key Dockerfile steps for Node.js Express apps?

Use lightweight base image, copy app, install deps, expose port, set NODE_ENV, run. Docker containerization fundamentals for Node.js.

Vue, Angular & Svelte2 min read

Angular Universal server memory leak: causes and diagnosis

Incomplete platform destruction, global DOM polyfills, unclosed RxJS; use heap snapshots and --inspect. Angular SSR platform lifecycle in Node.js and cross-request retainers. blaming Angular, not citing request cleanup.

React & Next.js2 min read

Kent C. Dodds Fixes Accidental Monorepo with Workspaces

Kent C. Dodds consolidated four deployable apps into a proper npm workspace, deleting three nested lockfiles and adding minimal Nx caching. The migration exposed hardcoded paths and invalid package aliases that broke production once Node enforced package…

Node.js & Express2 min read

Bcrypt: Hash Passwords with Salt and Slowness

Bcrypt salts and slows every password hash so identical passwords never look the same and brute force stays expensive. Use it in register and login routes before the database. Never compare hashes with plain string equality; always call bcrypt.compare().

Node.js & Express2 min read

Callback Hell: The Pyramid of Doom

Callback hell is what happens when nested async callbacks indent so deeply the code forms an unreadable pyramid. You see it in legacy Node.js when chaining database queries or file reads.

Node.js & Express2 min read

Node.js Built-in SQLite Driver

Node.js bundles a SQLite driver in node:sqlite. Open a file with new DatabaseSync(path), then run SQL with exec() or prepared statements. Use it for local tools and caches. DatabaseSync is synchronous, so running it on a web server main thread blocks requests.

Node.js & Express2 min read

Node.js Callbacks: Functions That Run Later

A callback is a function you pass to run later when an event fires or work finishes, keeping Node.js free to handle other work. HTTP servers use them to respond to connections without blocking.

TypeScript & Web APIs2 min read

Callback Hell: Navigating JavaScript's Async Pyramid

Callback Hell is the 'pyramid of doom' structure from nesting async functions. It happens when chaining I/O tasks like API calls, where each step depends on the last. The footgun is writing async code as if it runs sequentially, creating unreadable nests.

React & Next.js2 min read

Next.js Runtimes: Edge vs. Node.js

Choose your server environment in Next.js: a fast, limited Edge function or a powerful Node.js backend. Use the Edge for low-latency tasks like auth checks; stick with Node.js for its full API set and heavier computation.

Node.js & Express2 min read

Production Secret Management: Inject, Don't Store

Treat secrets like temporary credentials, injected at runtime, not stored with your code. This applies to database passwords and API keys in production. The biggest footgun is using .env files; they are a dev convenience, not a security model.

Node.js & Express2 min read

Heap Snapshots: Finding Node.js Memory Leaks

A heap snapshot is a photograph of your app's memory. Use it to diagnose leaks by comparing snapshots over time to see which objects grow. The big footgun: taking one freezes your app and can double memory usage, risking a crash in production.

Node.js & Express2 min read

Sinon.JS: Isolate and Inspect Code for Unit Tests

Sinon.JS lets you replace real functions with test doubles to check *if* and *how* they were called. Use it to fake network requests or control timers. The biggest footgun is forgetting to restore fakes, which causes tests to leak state and fail unpredictably.

Node.js & Express2 min read

Non-Blocking I/O: Don't Block the Event Loop

Non-blocking I/O lets your program do other work while waiting for slow operations like network requests. It's the core of Node.js, allowing a single thread to serve many users.

Node.js & Express2 min read

CI/CD Pipelines for Node.js Applications

A CI/CD pipeline is an automated assembly line for Node.js code, installing dependencies, running tests, and packaging your app for deployment. This is standard for any professional project, but a common footgun is not caching dependencies, leading to slow…

Node.js & Express2 min read

Environment-Specific Config: Beyond Hardcoded Values

Think of config as layered transparencies: a base file sets defaults, and environment-specific files (like `production.json`) override them. This keeps database hosts and feature flags tidy across dev, staging, and prod.

Node.js & Express2 min read

NODE_ENV: Flipping the 'Production' Switch

Setting NODE_ENV=production is like telling your Node.js app it's showtime, not rehearsal. This triggers performance optimizations in frameworks like Express, such as view caching and less verbose errors.

Node.js & Express2 min read

Node.js Buffers: Handling Raw Binary Data

A Node.js Buffer is a fixed-size chunk of memory for raw binary data, like an array of bytes. Use it for file I/O or network streams where JS strings fail. The footgun is using `allocUnsafe()` without overwriting it, which can leak old, sensitive data.

Node.js & Express2 min read

Preventing Sensitive Data Exposure in Node.js

Sensitive data exposure isn't just about database breaches; it's about accidentally leaking secrets. This happens when Node.js apps expose config files, API keys, or raw error messages, often by committing secrets to Git or failing to encrypt data.

Node.js & Express2 min read

XSS Prevention: Context-Aware Output Encoding

Prevent XSS by encoding all untrusted data just before it's rendered. The key is context: escaping for an HTML body is different from an attribute or script tag. This is critical for displaying user content.

Node.js & Express2 min read

E2E Testing: The Final Check, Not The Whole Strategy

E2E testing is a dress rehearsal for your app, simulating a full user journey. Use it sparingly for critical flows like checkout, as it tests all services together. The footgun is over-reliance: they are slow, brittle, and hard to debug.

Node.js & Express2 min read

Test Doubles: Mocks, Stubs, and Spies

A test double is a stand-in for a real component, letting you test code in isolation. Use them to fake slow dependencies like database calls or external APIs, making tests fast and predictable.

Node.js & Express2 min read

Supertest: Test Node.js APIs Without the Boilerplate

Supertest lets you test your Node.js API without running a separate server. Use it in Jest or Mocha to make requests to your routes and assert on responses. The footgun: since it's in-process, state can leak between tests if not reset properly.

Node.js & Express2 min read

Joi: Declarative Schemas for Data Validation

Joi lets you describe your data's shape with a readable schema instead of writing manual validation logic. It's used to validate API request bodies or config files.

Node.js & Express2 min read

Custom Error Classes: Beyond Generic Errors

Create specific error types, like `NotFoundError`, instead of generic ones. This lets your code react differently to different failures, like sending a 404 for a missing user vs. a 500 for a database outage.

Get Node.js bites daily.

Five a day, five minutes, offline. With quizzes so it sticks.

Open testing — you’ll join as an early tester.