• 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

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

NEW
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