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

statuscompliance / status-backend / 14383738041

10 Apr 2025 03:00PM UTC coverage: 30.825% (+3.3%) from 27.524%
14383738041

Pull #116

github

web-flow
Merge f209c5691 into e33452978
Pull Request #116: tests(script): added controller

136 of 602 branches covered (22.59%)

Branch coverage included in aggregate %.

499 of 1458 relevant lines covered (34.22%)

2.3 hits per line

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

10.71
/src/middleware/validation.js
1
import { validationResult } from 'express-validator';
2
import { validate as isUUID } from 'uuid';
3

4
export const checkIdParam = (req, res, next) => {
7✔
5
  if (!req.params.id) {
×
6
    return res.status(400).json({ error: 'Missing required parameter: id' });
×
7
  }
8
  next();
×
9
};
10

11
// Middleware to validate a parameter as UUIDv4
12
export const validateUUID = (paramName) => {
7✔
13
  return (req, res, next) => {
98✔
14
    const paramValue = req.params[paramName] || req.query[paramName] || req.body[paramName];
×
15
    if (!paramValue && !isUUID(paramValue) && !isGrafanaUID(paramValue)) {
×
16
      console.log('HERE');
×
17
      return res.status(400).json({ error: `Invalid or missing UUID for parameter: ${paramName}` });
×
18
    }
19
    next();
×
20
  }
21
};
22

23

24
export function validateParams(req, res, next) {
25
  const errors = validationResult(req);
×
26

27
  if (!errors.isEmpty()) {
×
28
    return res.status(400).json({ errors: errors.array() });
×
29
  }
30
  next();
×
31
};
32

33
function isGrafanaUID(uid) {
34
  return /^[a-zA-Z0-9]{12,24}$/.test(uid);
×
35
}
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