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

ULL-ESIT-INF-DSI-2526 / grp02-medcore-api-groupd / 25628398609

10 May 2026 12:08PM UTC coverage: 87.197% (-0.5%) from 87.738%
25628398609

push

github

eduzu
Merge branch 'main' of github.com:ULL-ESIT-INF-DSI-2526/grp02-medcore-api-groupd
Medication controllers and basic testing

99 of 109 branches covered (90.83%)

Branch coverage included in aggregate %.

279 of 320 new or added lines in 31 files covered. (87.19%)

1 existing line in 1 file now uncovered.

405 of 469 relevant lines covered (86.35%)

7.92 hits per line

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

94.44
/src/controller/record/readRecordById.controller.ts
1
import { readRecordById } from '../../services/record/readRecordById.js';
2
import { Request, Response } from 'express';
3
import mongoose from 'mongoose';
4

5
/**
6
 * Controlador para leer un registro médico por su ID.
7
 * @param req - Request
8
 * @param res - Response
9
 * @returns retorna un error o el registro médico encontrado por su ID.
10
 */
11
export async function readRecordByIdController(req: { params: { id: string } }, res: Response) {
12
    try {
6✔
13
        const { id } = req.params;
6✔
14
        if (!mongoose.isValidObjectId(id)) {
6✔
15
            return res.status(400).json({ error: 'Invalid record ID' });
1✔
16
        }
17
        const objectId = new mongoose.Types.ObjectId(id);
5✔
18
        const record = await readRecordById(objectId);
5✔
19
        if (!record) {
3✔
20
            return res.status(404).json({ error: 'Record not found' });
1✔
21
        }
22
        res.json(record);
2✔
23
    } catch (error) {
24
        if (error instanceof mongoose.Error.ValidationError) {
2✔
NEW
25
            return res.status(400).json({ error: error.message });
×
26
        }
27
        if (error instanceof Error) {
2✔
28
            return res.status(500).json({ error: error.message });
1✔
29
        }
30
        res.status(500).json({ error: 'Internal server error' });
1✔
31
    }
32
}   
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