Learn how to write cleaner NestJS by creating Dynamic Modules easily with the Configurable Module Builder.
Length 13:18
Captions English (Generated), Spanish (Auto-translated), French (Auto-translated), Korean (Auto-translated), Portuguese (Auto-translated), Vietnamese (Auto-translated) #nestjs #dynamic modules #configurable module builder #typescript #software development #coding tutorial #programming #web development #node.js #backend
0:00 Hey guys. Today I wanted to show you how we can 0:02 write very clean 0:04 NestJS 0:05 dynamic modules by using the configurable module 0:09 builder. 0:10 So dynamic modules in NestJS are custom modules that we 0:14 can create 0:15 and expose to other NestJS applications. 0:19 These NestJS applications can provide the dynamic module with 0:23 options provided asynchronously 0:26 or synchronously, and then these options are then used 0:29 by the dynamic module to set up its own 0:33 providers, controllers, or whatever dependencies it needs to 0:36 export. Now, usually writing these dynamic modules 0:40 is quite 0:40 complex in NestJS. However, NestJS offers us a 0:44 very useful API builder class to actually create these 0:48 dynamic modules super easily. 0:50 In this lecture, I wanna show you how we can use this 0:53 configurable module 0:54 builder to write very clean dynamic modules very 0:58 easily. So let's go ahead and get started 1:02 by using the Nest CLI to generate a new project. 1:06 I'll call this Config Module Builder, 1:10 and I'll use pnpm to install. So I'll then CD 1:14 into our project after our dependency's installed, 1:17 and I'll open up this project in VS Code. 1:21 Also go ahead and start up the server by running pnpm start dev. 1:25 So we have our basic NestJS application out of the box. 1:31 Now I want to turn this into a workspace 1:35 where we have multiple different applications and common 1:38 libraries that those applications can consume. 1:42 So NestJS supports this in a monorepo structure by 1:47 running Nest generate 1:50 app, and then we can call this application 1:53 whatever we'd like. 1:55 I'll go ahead and call it Main. 1:58 So now we've converted our application into a workspace, 2:02 which has given us two separate applications, our original 2:06 one we started with and a new main application, 2:11 which are two separate NestJS applications, each with 2:14 their own bootstrap functions that will listen
The rest of the transcript is for members.
Sign in