import { Module } from "@nestjs/common"; import { ConfigService } from "@nestjs/config"; import { MongooseModule } from "@nestjs/mongoose"; @Module({ imports: [ MongooseModule.forRootAsync({ inject: [ConfigService], useFactory: (configService: ConfigService) => ({ uri: configService.get("MONGO_URI"), tls: configService.get("MONGO_TLS") === "true", tlsAllowInvalidCertificates: configService.get("MONGO_TLS_ALLOW_INVALID_CERTS") === "true", autoIndex: configService.get("NODE_ENV") !== "production", }), }), ], }) export class DatabaseModule {}