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

mongodb-js / mongodb-mcp-server / 20852798965

09 Jan 2026 01:03PM UTC coverage: 79.538% (-0.1%) from 79.647%
20852798965

Pull #837

github

web-flow
Merge 9b3bafc92 into 7043c219d
Pull Request #837: chore: minimize node-specific API usage

1509 of 1967 branches covered (76.72%)

Branch coverage included in aggregate %.

13 of 25 new or added lines in 5 files covered. (52.0%)

19 existing lines in 2 files now uncovered.

6899 of 8604 relevant lines covered (80.18%)

89.32 hits per line

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

44.44
/src/helpers/getRandomUUID.ts
1
import { UUID } from "bson";
3✔
2
/**
3
 * Generates a random UUID that works in both Node.js and browser environments.
4
 * Attempts to use Node.js crypto first, then falls back to Web Crypto API.
5
 */
6
export function getRandomUUID(): string {
3✔
7
    try {
176✔
8
        // Try Node.js crypto module first
9
        // Using require to avoid import errors in browser environments
10
        // eslint-disable-next-line @typescript-eslint/no-require-imports, @typescript-eslint/consistent-type-imports
11
        const nodeCrypto = require("crypto") as typeof import("crypto");
176✔
12
        return nodeCrypto.randomUUID();
176✔
13
    } catch {
176!
14
        // Fall back to Web Crypto API (available in browsers and modern Node.js)
NEW
15
        if (
×
NEW
16
            typeof globalThis !== "undefined" &&
×
NEW
17
            globalThis.crypto &&
×
NEW
18
            typeof globalThis.crypto.randomUUID === "function"
×
NEW
19
        ) {
×
NEW
20
            return globalThis.crypto.randomUUID();
×
NEW
21
        }
×
22

23
        // If neither is available, use the BSON UUID
NEW
24
        return new UUID().toString();
×
NEW
25
    }
×
26
}
176✔
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