discotools / lib /mongo.ts
enzostvs's picture
enzostvs HF Staff
Upload 172 files
9cd6ddb verified
raw
history blame contribute delete
386 Bytes
import { MongoClient } from "mongodb";
const uri = process.env.MONGO_DB_URI;
const options = {
useUnifiedTopology: true,
useNewUrlParser: true,
};
let client: any;
let clientPromise: any;
if (!process.env.MONGO_DB_URI) {
throw new Error("Add Mongo URI to .env.local");
}
client = new MongoClient(uri, options);
clientPromise = client.connect();
export default clientPromise;