MCPcopy Index your code
hub / github.com/wei/pull / connectMongoDB

Function connectMongoDB

src/configs/database.ts:5–13  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

3import log from "@/src/utils/logger.ts";
4
5export const connectMongoDB = async () => {
6 if (mongoose.connection.readyState !== 1) {
7 await mongoose.connect(appConfig.mongoDBUrl!);
8 }
9 if (mongoose.connection.readyState !== 1) {
10 throw new Error("[MongoDB] Failed to connect");
11 }
12 log.info("[MongoDB] Connected");
13};
14
15export const disconnectMongoDB = async () => {
16 await mongoose.disconnect();

Callers 3

index.tsFile · 0.90
mainFunction · 0.90
mainFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected