NestJS
a framework for building the server side of TypeScript applications, separating routes, business rules and data access into modules.
- GitHub stars
- 76,921
- weekly package downloads
- 16.5M
documented use at
- sportswear and footwear brand.
- technology company that sells software, cloud and consulting to other businesses.
- platform where teams store code, review changes and automate software releases.
- German maker of cars and motorcycles.
- company that builds programming tools such as IntelliJ IDEA, and the Kotlin language.
source: docs.nestjs.com
merged#18308+245−269
a NestJS application is split into modules that use one another, and each module can run a routine when it starts and another when it shuts down, such as opening and closing the database connection. the documentation promises that a module starts after the modules it depends on and shuts down before them. since version 11.0.9, when a module was also reached through a longer path, that order could flip: a service queried the database before the connection opened and again after it closed. the fix computes each module's position from the longest path to it, and the promised order holds again for any shape of dependencies.
what has been verifiedthe service queried a disconnected database; startup, shutdown and middleware-order tests fail before the change and pass after. ordering 2,000 modules went from 260 ms to 1 ms
fix(core): run the hooks of imported modules before their importers
see the pull requestmerged#18343+652−56
NestJS can warn when two routes answer the same path, refuse to start the server in that case, and sort routes so a fixed path, like /releases/v1, wins over a path with a variable, like /releases/v:version. to compare them, it split the path on slashes and only understood segments that were entirely a variable. optional parts (users{/:id}) and text next to a variable (v:version, :name.:extension) were misread: routes that answered the same request went unreported, the sorting sent /releases/v1 to the route with the variable, and two routes that never overlap stopped the server from starting. the fix reads each path with the routing library, including these formats, and the warning, the startup check and the order now reflect the routes that actually overlap.
what has been verifiedGET /users/5 went to the wrong route with no warning; 11 new tests and real requests against an Express server fail before the change and pass after
fix(core): read optional groups and mixed segments when comparing routes
see the pull requestmerged#18305+111−9
one service can answer on several hostnames, and NestJS checks whether two identical routes compete for the same hostname. to do that, it only checked that both lists had the same length and that every hostname in the first appeared in the second. so a list that repeated a hostname was treated as equal to a list with a different hostname: the second route was dropped and anyone using the other hostname got "not found"; with the strictest conflict rule, the server did not even start. the fix compares the lists in both directions, and both routes stay active.
what has been verifiedthe route on the second hostname returned 404; tests with real requests fail before the change and pass after it
fix(core): tell host lists apart when one repeats a host
see the pull request

