Our great sponsors
-
Nest
A progressive Node.js framework for building efficient, scalable, and enterprise-grade server-side applications with TypeScript/JavaScript 🚀
-
SurveyJS
Open-Source JSON Form Builder to Create Dynamic Forms Right in Your App. With SurveyJS form UI libraries, you can build and style forms in a fully-integrated drag & drop form builder, render them in your JS app, and store form submission data in any backend, inc. PHP, ASP.NET Core, and Node.js.
I decided to write this article when I was browsing NestJS issues, in particular A Guard with dependencies can’t be injected into another module. Its author wonders why NestJS cannot resolve dependency for AuthGuard, because this dependency is imported into the module where the guard is declared.
This code demonstrates the centralized addition of a guard to a module, and by the way, NestJS v9 still doesn’t support this feature. In NestJS, adding a guard is supported only at the controller or method level, because the guard is not considered a provider.