NodeLib nodejs api logoNodeLib
node · nodejs · node-js

API reference (concise map)

This page summarizes the public surface area as understood by most node js adopters. Names are illustrative until your pinned release matches the reference tag.

Version family: v3.x (illustrative) Back to getting started

Factories

Entry constructors for composing a nodejs application shell with explicit dependencies.

Primary factory functions
SymbolPurposeNotes
createHttpAppBuild a request router with middleware stagingTransport-agnostic where possible for node-js tests
createContextBind per-request services (logger, id factory)Keep context narrow to preserve reviewer clarity

HTTP helpers

node js http handler layers diagram
Layering diagram: transport, validation, domain, persistence.
Common HTTP utilities
UtilityWhen to useAvoid
parseJsonBodyControlled JSON parsing with size limitsParsing untrusted bodies before size checks
sendProblemConsistent problem+json responsesLeaking internal stack traces to clients

Errors

Error types are designed to classify failures for operators without coupling logs to a single vendor format.

Error families
TypeMeaningHTTP mapping (typical)
ValidationErrorInput failed schema checks400 class
AuthnErrorAuthentication missing or invalid401 class
AuthzErrorAuthenticated but not permitted403 class

Telemetry seams

Hooks emit timing spans and counters using interfaces you can bridge to OpenTelemetry or internal agents in node deployments.

Instrumentation hooks
HookEmitsRequired?
onRequestStartRequest id + route templateOptional but recommended
onHandlerFinishDuration + outcome classOptional

Stability index

Symbols marked experimental may change across minor releases until promoted. Pin versions and read migration notes for each nodejs upgrade cycle.