CodeVetter · Repo Unpack · Behavior traces
nestjs/nest
Three concrete flows were followed through source: HTTP startup, cats request handling, and TypeORM persistence. Startup separates dependency construction from later application initialization and listener creation. Request execution separates authorization from parameter transformation and wraps controller invocation with interceptors. Persistence is an application-level repository operation, with framework dependency injection supplying the repository.
- Startup step 1: cats bootstrap calls NestFactory.create(AppModule), installs ValidationPipe globally, and calls listen(3000).
- Startup step 2: NestFactory.create constructs ApplicationConfig and NestContainer, invokes initialize, creates NestApplication, preloads optional packages, and returns an adapter proxy.
- Startup step 3: initialize calls DependenciesScanner.scan, InstanceLoader.createInstancesOfDependencies, and applyApplicationProviders in that order.
- Startup step 4: listen calls init if needed; init registers parsers, modules, routes, initialization hooks, router error handlers, and bootstrap hooks before adapter.listen opens the listener.
- Cats POST step 1: controller metadata selects RolesGuard and the admin role; RolesGuard.canActivate reads role metadata and checks request.user.roles.
- Cats POST step 2: the execution closure runs guards, invokes interceptors around the handler, applies parameter pipes, and calls CatsController.create, which appends through CatsService.create.
- Cats GET follows CatsController.findAll to CatsService.findAll; the provider returns a promise containing the current in-memory array.
- Persistence setup: AppModule configures MySQL with entity autoloading; UsersModule.forFeature([User]) registers the repository injected into UsersService.
- Persistence write: POST /users calls UsersController.create, then UsersService.create, then repository.save(new User populated from the DTO), returning the resulting Promise<User>.