Coding task · NestJS course · Module 1: NestJS Basics

Configuration Validation with Joi

Add environment variable validation to ConfigModule.

Task

In the imports of AppModule, add ConfigModule.forRoot() with the validationSchema option: a Joi.object() schema in which PORT is a number (Joi.number() with a default of 3000) and DATABASE_URL is a required string (Joi.string().required()).