More in Backend Dev — page 3
asyncio.gather vs asyncio.wait
WHAT IT TESTS: Whether you know how each aggregates results and handles errors. OUTLINE: gather returns ordered results and propagates the first exception (or captures them); wait returns done/pending sets and never raises, you inspect each.
How FastAPI uses type hints for validation
WHAT IT TESTS: Whether you know FastAPI leans on Pydantic and type hints. OUTLINE: Hints drive parsing, validation, and conversion; a path declared int is coerced or returns 422; OpenAPI is auto-generated.
Diagnosing intermittent crashes with PM2
WHAT IT TESTS: using a process manager for resilience plus diagnosis. OUTLINE: PM2 auto-restarts and runs cluster mode for availability, inspect logs and metrics, watch memory for leaks, capture errors.
Unit testing Express auth middleware in isolation
WHAT IT TESTS: isolating and unit-testing middleware. OUTLINE: build fake req/res, use a spy/mock for next and res methods, assert next called on valid token and 401 sent on invalid.
JWT login and protected route flow in Express
WHAT IT TESTS: end-to-end JWT auth flow and storage tradeoffs. OUTLINE: verify credentials, sign a JWT, client stores and sends it (Authorization header or httpOnly cookie), middleware verifies signature on protected routes.
Defining many-to-many relationships in Sequelize
WHAT IT TESTS: modeling many-to-many with a join table. OUTLINE: use belongsToMany through a join table, the through table holds the foreign keys, eager-load courses with include.
Nested routes versus query params for related resources
WHAT IT TESTS: REST relationship modeling tradeoffs. OUTLINE: nested routes express ownership and scope clearly, query params on the flat resource are flexible for filtering and combining.
Callback hell and how to refactor it
WHAT IT TESTS: managing async control flow readably. OUTLINE: deeply nested callbacks (pyramid of doom) hurt readability and error handling, refactor with promises or async/await.
Blocking versus non-blocking I/O in Node
WHAT IT TESTS: core async model understanding. OUTLINE: blocking calls halt the thread until done, non-blocking returns immediately and notifies via callback or promise, fs.readFileSync versus fs.readFile.
Managing user presence with reconnection grace periods
WHAT IT TESTS: robust presence tracking over flaky networks. OUTLINE: rely on heartbeats, apply a grace period before marking offline, reconcile reconnects by user not socket id, use a shared store for multi-instance.
Pinpointing validation errors in nested request data
WHAT IT TESTS: structured error reporting for nested input. OUTLINE: use schema validation that reports a path, collect all errors not just the first, return a 400 with field paths and messages.
Purpose of an ORM like Sequelize
WHAT IT TESTS: understanding ORM value and tradeoffs. OUTLINE: maps rows to objects, gives a model-based API, handles associations, migrations, and parameterized queries across dialects.
Validating request bodies with Express middleware
WHAT IT TESTS: separating validation from business logic via middleware. OUTLINE: run validation middleware before the handler, check email format and password length, return 400 with errors on failure, call next on success.
V8 generational GC and event loop responsiveness
WHAT IT TESTS: how GC pauses affect Node latency. OUTLINE: young-generation scavenges are frequent but short, old-generation major GC is rarer but longer, stop-the-world pauses block the single JS thread.
Detecting and diagnosing event loop lag
WHAT IT TESTS: production diagnosis of a blocked single thread. OUTLINE: measure delay between scheduled and actual timer fire, expose it as a metric, find synchronous CPU-bound code.
Microtask versus macrotask execution order in Node
WHAT IT TESTS: precise grasp of event loop ordering. OUTLINE: nextTick drains before promises, both microtask queues flush fully between each macrotask, timers and setImmediate are macrotasks.
Role of libuv in the Node.js runtime
WHAT IT TESTS: understanding of how Node achieves async I/O. OUTLINE: libuv provides the event loop, a thread pool for blocking work, and OS async I/O abstractions. RED FLAG: claiming V8 itself runs the event loop or that Node is fully single-threaded.
Managing secrets for containerized Node.js on Kubernetes
WHAT IT TESTS: secure secret handling in orchestration. OUTLINE: use Kubernetes Secrets or an external vault, mount as files not env, encrypt at rest, rotate. RED FLAG: baking credentials into images or trusting plain env vars as secure.
Implementing a custom filtering Transform stream
WHAT IT TESTS: Knowing the Transform stream contract. OUTLINE: Subclass Transform with objectMode, implement _transform to parse each chunk, push only matching objects, and call the callback; handle parse errors.
worker_threads versus cluster: when to use each
WHAT IT TESTS: Matching the concurrency tool to the workload. OUTLINE: worker_threads offloads CPU-bound compute within one process with shared-memory transfer; cluster forks processes to scale IO-bound request throughput across cores.