NestJS Source Code Tracing
1 min readApr 25, 2020
NestJS is a very complex NodeJS HTTP Server Framework. It has lots of components, such as filter, guard and interceptor. At first, I really cannot understand why it works, so I tried to trace the source code.
This tutorial will be from the initial endpoint to the detail. Each part will add some comments.
Most of us will write some code like the following to setup http server by NestJS.
nest-factory.ts
NestFactory.create
NestFactory.initialize
DependenciesScanner.scan
InstanceLoader.createInstancesOfDependencies
InstanceWrapper.createPrototype
DependenciesScanner.applyApplicationProviders
NestApplication.constructor
RoutesResolver.constructor
createProxy
NestApplication.listen
Adapter.registerParserMiddleware
NestApplication.registerModules
MiddlewareModule.register
resolveMiddleware
MiddlewareBuilder.ConfigProxy.forRoutes