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

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

09 May 2026 03:28PM UTC coverage: 87.556% (+4.1%) from 83.451%
25604747705

push

github

DiegoPrietoG
feat: refactor readRecord functionality and improve controller logic. Added readRecord test

74 of 82 branches covered (90.24%)

Branch coverage included in aggregate %.

4 of 4 new or added lines in 2 files covered. (100.0%)

3 existing lines in 3 files now uncovered.

320 of 368 relevant lines covered (86.96%)

7.82 hits per line

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

92.86
/src/controller/staff/createStaffController.ts
1
import { createNewStaff } from '../../services/staff/createNewStaff.js';
2
import StaffInterface from '../../models/staff/staffInterface.js';
3

4
/**
5
 * Controlador para crear un nuevo miembro del personal.
6
 * @param req Request de la API, se espera que el cuerpo de la solicitud contenga los datos del nuevo miembro del personal.
7
 * @param res 
8
 * @returns 
9
 */
10
import mongoose from 'mongoose';
11
import { Request, Response } from 'express';
12

13
export async function createStaffController(req: Request, res: Response) {
14
  try {
7✔
15
    const createdStaff = await createNewStaff(req.body as StaffInterface);
7✔
16

17
    return res.status(201).json(createdStaff);
2✔
18

19
  } catch (error: unknown) {
20

21
    // Validation error de Mongoose
22
    if (error instanceof mongoose.Error.ValidationError) {
5✔
23
      return res.status(400).json({
3✔
24
        error: error.message,
25
      });
26
    }
27

28
    if (error instanceof Error) {
2✔
29
      const mongoError = error as Error & { code?: number };
2✔
30

31
      if (mongoError.code === 11000) {
2✔
32
        return res.status(409).json({
1✔
33
          error: 'Staff member already exists in the system',
34
        });
35
      }
36

37
      return res.status(500).json({
1✔
38
        error: error.message,
39
      });
40
    }
41

UNCOV
42
    return res.status(500).json({
×
43
      error: 'Internal Server Error',
44
    });
45
  }
46
}
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