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

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

09 May 2026 09:33AM UTC coverage: 46.333% (-23.1%) from 69.421%
25597798255

push

github

Diegoarmas
Implement Records functionality: add controller, router, and tests; enhance Medications routes and controller

8 of 31 branches covered (25.81%)

Branch coverage included in aggregate %.

24 of 62 new or added lines in 5 files covered. (38.71%)

36 existing lines in 4 files now uncovered.

131 of 269 relevant lines covered (48.7%)

0.7 hits per line

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

10.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;
1✔
4

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

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

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

29
export async function disconnectDB(): Promise<void> {
UNCOV
30
  try {
×
UNCOV
31
    await mongoose.disconnect();
×
UNCOV
32
    console.log('Mongoose disconnected');
×
33
  } catch (err: any) {
UNCOV
34
    console.error('Mongoose disconnect error:', err);
×
UNCOV
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