File size: 532 Bytes
656c481
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import { MongoClient } from "mongodb";
import { AuthenticationCreds } from "@whiskeysockets/baileys";

const dbName = "whatsapp";
const collectionName = "authState";

interface AuthDocument extends Document {
  _id: string;
  creds?: AuthenticationCreds;
}

async function connectDB() {
  const client = new MongoClient(process.env.MONGO_URL || "");
  await client.connect();
  const db = client.db(dbName);
  const collection = db.collection<AuthDocument>(collectionName);
  return { client, collection };
}

export { connectDB };