• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

ULL-ESIT-INF-DSI-2526 / grp02-medcore-api-groupf / 25613285994

09 May 2026 10:21PM UTC coverage: 78.27%. First build
25613285994

push

github

Diegoarmas
Merge branch 'dev'

# Conflicts:
#	package.json

45 of 70 branches covered (64.29%)

Branch coverage included in aggregate %.

326 of 404 new or added lines in 17 files covered. (80.69%)

326 of 404 relevant lines covered (80.69%)

5.19 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

75.0
/src/db/database.ts
1
import mongoose from 'mongoose';
2

3
const mongoUri = process.env.ATLAS_URI ?? process.env.MONGODB_URL ?? process.env.MONGODB_URI;
7✔
4

5
export async function connectDB(): Promise<typeof mongoose> {
6
  if (!mongoUri) {
9✔
NEW
7
    throw new Error(
×
8
      'No MongoDB URI specified in env (ATLAS_URI, MONGODB_URL or MONGODB_URI)'
9
    );
10
  }
11

12
  try {
9✔
13
    await mongoose.connect(mongoUri);
9✔
14
    console.log(`Mongoose connected to: ${mongoose.connection.name}`);
9✔
15
    return mongoose;
9✔
16
  } catch (err: any) {
NEW
17
    console.error('Mongoose connection error:', err);
×
NEW
18
    throw err;
×
19
  }
20
}
21

22
export function getDb() {
23
  if (mongoose.connection.readyState !== 1) {
2✔
24
    throw new Error('Database not connected. Call connectDB() first.');
1✔
25
  }
26
  return mongoose.connection.db;
1✔
27
}
28

29
export async function disconnectDB(): Promise<void> {
30
  try {
10✔
31
    await mongoose.disconnect();
10✔
32
    console.log('Mongoose disconnected');
10✔
33
  } catch (err: any) {
NEW
34
    console.error('Mongoose disconnect error:', err);
×
NEW
35
    throw err;
×
36
  }
37
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc