Better error message when .env file is missing (#9)

This commit is contained in:
Ângelo Tadeucci 2023-06-02 11:35:14 -03:00 committed by GitHub
parent 108d2c621d
commit ec95bab507
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -5,9 +5,9 @@ dotenv.config();
const url = process.env.MONGODB_URL;
if (!url) throw new Error("MONGODB_URL not found");
console.log("connecting to MongoDB URL:", url);
if (url === undefined) {
throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
}
const connectDatabase = async () => {
try {