Skip to content

Common

concept
2 min readUpdated

What it is responsible for

Common manages shared, framework-facing declarations and input-pipe entry points for the codebase. Its documentation says that the common package comes with decorators such as @Controller() and @Injectable(). Work enters through DefaultValuePipe, ParseFilePipe, ParseArrayPipe, and ParseBoolPipe; related named pipes cover boolean, date, enum, float, integer, UUID, and validation cases. Common also names logging, serialization, middleware, route, and configuration abstractions, placing those cross-cutting symbols under one package boundary.

What it needs, and who needs it

Common needs no dependency within this repository. Its consumers include Core, Cats, and integrations for injector, inspector, scopes, discovery, GraphQL code-first, and hello-world. Without this package, those dependents lose the listed source of common decorators, pipes, interfaces, types, constants, and classes; their references to symbols such as ValidationPipe or Logger would no longer have this declared upstream package.

Notable members

DefaultValuePipe is a work-entry member and signals the default-value pipe path. ParseFilePipe is another work-entry member, representing the file-parsing pipe path. MiddlewareConsumer stands out because the documentation explicitly defines an interface for applying user-defined middleware to routes; MiddlewareConfiguration, MiddlewareConfigProxy, NestMiddleware, and RouteInfo place that interface in a named middleware-and-routing group. ConsoleLogger and Logger similarly mark logging as part of Common’s shared surface.

353 entities in packages/common. 8 other subsystems depend on it, which makes it the most depended-upon part of this codebase.

What it is made of

Its 353 entities sit in 161 files under packages/common: 92 interfaces, 85 functions, 63 constants, 32 type aliases and 81 more. route-params.decorator.ts holds 36 of them — more than any other file here. HttpException declares 12 methods, the widest surface here.

Where work enters

How it refuses and fails

6 of its components record a refusal or a failure handler. All 6 of them refuse work outright, under a condition written into the component itself. Their catch blocks handle a failure that already happened in 2 places. Of those 2, 1 logs it and continues and 1 turns it into a return value.

Boundaries

8 other subsystems depend on this oneCore, Microservices, Platform Express, Testing, Platform Fastify, Platform Socket.io, Platform Ws, Websockets. Changing what it exposes changes them.

Those 8 hold 742 edges between them, unevenly: Core reaches in across 471 edges, against 2 from Platform Socket.io. What they reach is narrower than the folder: 140 of its 353 members carry every inbound edge — Type (59), Logger (40) and isUndefined (29), plus 137 more.

It depends on no other subsystem in this repository — it is a leaf.

How this code is named

These conventions cover most of the codebase. Learning them is faster than reading an index — each one lets you find any member of its family without looking it up.

PatternWhereCountExamples
*.interface.tsacross the repository67type.interface.ts, file.interface.ts, on-init.interface.ts, abstract.interface.ts
*.decorator.tsacross the repository24sse.decorator.ts, bind.decorator.ts, catch.decorator.ts, inject.decorator.ts
*.exception.tspackages/common/exceptions/23gone.exception.ts, http.exception.ts, conflict.exception.ts, forbidden.exception.ts
*.util.tsacross the repository16cli-colors.util.ts, forward-ref.util.ts, is-log-level.util.ts, load-package.util.ts

Was this page helpful?

Download as PDF
Common — NestJS head-to-head