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

dreamsparkx / node-ts-starter / 13675028562

05 Mar 2025 11:32AM UTC coverage: 79.855% (-3.1%) from 82.915%
13675028562

Pull #1136

github

Gaurav Bharti
chore(yml): remove yml
Pull Request #1136: feat(migrate): migrate to pnpm

66 of 91 branches covered (72.53%)

Branch coverage included in aggregate %.

13 of 13 new or added lines in 1 file covered. (100.0%)

57 existing lines in 9 files now uncovered.

596 of 738 relevant lines covered (80.76%)

1.82 hits per line

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

90.54
/src/controllers/user/validators.ts
1
import Joi from "joi";
1✔
2
import { Response, Request, NextFunction } from "express";
3
import { BadRequestError } from "../../util/error";
1✔
4

5
const UserJoiSchema = Joi.object().keys({
1✔
6
  email: Joi.string().email().required(),
1✔
7
  password: Joi.string().min(1).required(),
1✔
8
});
1✔
9

10
export const createUser = async (
1✔
11
  req: Request,
3✔
12
  res: Response,
3✔
13
  next: NextFunction,
3✔
14
) => {
3✔
15
  try {
3✔
16
    const { error } = UserJoiSchema.validate(req.body);
3✔
17
    if (error) {
3✔
18
      const { details } = error;
1✔
19
      throw new BadRequestError("Validation Errors", details);
1✔
20
    }
1✔
21
  } catch (err) {
3✔
22
    return next(err);
1✔
23
  }
1✔
24
  return next();
2✔
25
};
2✔
26

27
export const updateUser = async (
1✔
28
  req: Request,
1✔
29
  res: Response,
1✔
30
  next: NextFunction,
1✔
31
) => {
1✔
32
  try {
1✔
33
    const { error } = Joi.object()
1✔
34
      .keys({
1✔
35
        email: Joi.string().email().optional(),
1✔
36
        password: Joi.string().when("email", {
1✔
37
          is: Joi.exist(),
1✔
38
          then: Joi.optional(),
1✔
39
          otherwise: Joi.required(),
1✔
40
        }),
1✔
41
      })
1✔
42
      .validate(req.body);
1✔
43
    if (error) {
1!
44
      const { details } = error;
×
45
      throw new BadRequestError("Validation Errors", details);
×
UNCOV
46
    }
×
47
  } catch (ex) {
1!
48
    return next(ex);
×
UNCOV
49
  }
×
50
  return next();
1✔
51
};
1✔
52

53
export const loginUser = async (
1✔
54
  req: Request,
5✔
55
  res: Response,
5✔
56
  next: NextFunction,
5✔
57
) => {
5✔
58
  try {
5✔
59
    const { error } = UserJoiSchema.validate(req.body);
5✔
60
    if (error) {
5✔
61
      const { details } = error;
1✔
62
      throw new BadRequestError("Validation Errors", details);
1✔
63
    }
1✔
64
  } catch (err) {
5✔
65
    return next(err);
1✔
66
  }
1✔
67
  return next();
4✔
68
};
4✔
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