Configure a NestJS API with Environment Variables using ConfigModule and joi

InstructorBram Borggreve

Share this video with your friends

Send Tweet

In this lesson, we add configuration to the NestJS API using a .env file, which Nx Workspace supports out of the box.

After adding the @nestjs/config and joi dependencies, we define a configuration and validation schema.

These files are loaded into the ConfigModule, that we import in CoreModule and the values in our .env file are now validated using our schema.

We can now import the ConfigService and use it to get properties from our configuration.

~ 2 years ago

Dumb question, since I'm new to egghead: does this lesson belong to a course, and how do I figure it out? Thanks!