How to register providers in environment injector in Angular

Loading

Reading Time: 5 minutes Introduction In this blog post, I describe how to register providers in environment injector in Angular. One way to create an environment injector is to use the ENVIRONMENT_INITIALIZER token. When I have several providers and they don’t have to execute any logic during bootstrap, I can use makeEnvironmentProviders to wrap an array of providers to … Read more

Mastering Angular’s Hierarchical Dependency Injection with inject() Function

Loading

Reading Time: 5 minutes Introduction Before Angular 14, Angular achieves hierarchical dependency injection by injecting services in constructor and applying combination of @Host, @Self, @SkipSelf() and @Optional() decorators. In Angular 14, Angular team introduces inject() and it accepts inject options that can achieve the results. In this blog post, I am going to illustrate how to pass different inject … Read more

Stripe Integration In NestJS

Loading

Reading Time: 6 minutes Scenario: Our ESG (Environmental, Social, and Governance) platform offers monthly and annual subscriptions to charge customers for using our ESG reporting service. When we designed our payment module, we chose Stripe as our payment platform because it accepts credit card payment method, provides good documentations and open source node library for the API (stripe-node). Problem: … Read more

Dependency injection by abstract class in NestJS

Loading

Reading Time: 3 minutes When developers start using NestJS, they create new module with controllers and services to design backend APIs. Developers register controllers and services in the module and inject service into controller to perform CRUD operations. Provider Registration The following is a code snippet of a user module; user controller is registered in controller array while user … Read more