Skip to content

Commit

Permalink
fix: use dotenv in mongodb.ts file
Browse files Browse the repository at this point in the history
  • Loading branch information
WhyAsh5114 committed Oct 14, 2024
1 parent 4e8d2b3 commit 50d3884
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/lib/mongo/mongodb.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
// This approach is taken from https://github.com/vercel/next.js/tree/canary/examples/with-mongodb
import { MongoClient } from 'mongodb';
import { MONGODB_URI } from '$env/static/private';
import dotenv from 'dotenv';
dotenv.config();

const MONGODB_URI = process.env.MONGODB_URI;
if (!MONGODB_URI) {
throw new Error('Invalid/Missing environment variable: "MONGODB_URI"');
}
Expand Down

0 comments on commit 50d3884

Please sign in to comment.