Better error message when .env file is missing #9
@ -5,9 +5,9 @@ dotenv.config();
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
const url = process.env.MONGODB_URL;
 | 
					const url = process.env.MONGODB_URL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
if (!url) throw new Error("MONGODB_URL not found");
 | 
					if (url === undefined) {
 | 
				
			||||||
 | 
					    throw new Error("MONGODB_URL not found. Make sure you have a .env file in the root of the project!");
 | 
				
			||||||
console.log("connecting to MongoDB URL:", url);
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
const connectDatabase = async () => {
 | 
					const connectDatabase = async () => {
 | 
				
			||||||
    try {
 | 
					    try {
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user