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{DiscussionModel as a}from"../../models/discussion.model.mjs";import{AuditModel as o}from"../../models/audit.model.mjs";import{AuditJobModel as s}from"../../models/auditJob.model.mjs";import{AuditPageModel as c}from"../../models/auditPage.model.mjs";import{OAuth2AccessTokenModel as l}from"../../models/oAuth2.model.mjs";import{ShowcaseProjectModel as u}from"../../models/showcaseProject.model.mjs";import{UserModel as d}from"../../models/user.model.mjs";import{connect as f}from"mongoose";let p=null;const m=async()=>{try{let m=await f(`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 a.syncIndexes(),await d.createIndexes(),await l.createIndexes(),await i.createIndexes(),await t.createIndexes(),await n.createIndexes(),await u.syncIndexes(),await o.syncIndexes(),await s.syncIndexes(),await c.syncIndexes(),p=m.connection.getClient(),p}catch(t){let n=`MongoDB connection error - ${t.message}`;throw e.error(n),Error(n)}},h=()=>{if(!p)throw Error(`Database not connected. Call connectDB() first.`);return p};export{m as connectDB,h as getDBClient};
//# sourceMappingURL=connectDB.mjs.map