import{logger as e}from"../../logger/index.mjs";import{DictionaryModel as t}from"../../models/dictionary.model.mjs";import{OrganizationModel as n}from"../../models/organization.model.mjs";import{ProjectModel as r}from"../../models/project.model.mjs";import{TagModel as i}from"../../models/tag.model.mjs";import{OAuth2AccessTokenModel as a}from"../../models/oAuth2.model.mjs";import{UserModel as o}from"../../models/user.model.mjs";import{connect as s}from"mongoose";let c=null;const l=async()=>{try{let l=await s(`mongodb+srv://${process.env.DB_ID}:${process.env.DB_MDP}@${process.env.DB_CLUSTER}/?retryWrites=true&w=majority&appName=Cluster0`);return e.info(`MongoDB connected`),await r.syncIndexes(),await o.createIndexes(),await a.createIndexes(),await i.createIndexes(),await t.createIndexes(),await n.createIndexes(),c=l.connection.getClient(),c}catch(t){let n=`MongoDB connection error - ${t.message}`;throw e.error(n),Error(n)}},u=()=>{if(!c)throw Error(`Database not connected. Call connectDB() first.`);return c};export{l as connectDB,u as getDBClient};
//# sourceMappingURL=connectDB.mjs.map