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

nestjs / nest / ae0182d5-3e47-4d23-8019-8cf995f68613

16 Jan 2025 02:20PM UTC coverage: 52.407% (-37.3%) from 89.728%
ae0182d5-3e47-4d23-8019-8cf995f68613

Pull #14433

circleci

web-flow
Update enable-shutdown-hook.spec.ts
Pull Request #14433: Fix process not ending correctly with shutdown hooks

1357 of 3328 branches covered (40.78%)

4148 of 7915 relevant lines covered (52.41%)

6.49 hits per line

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

14.29
/packages/microservices/utils/transform-pattern.utils.ts
1
import {
1✔
2
  isObject,
3
  isString,
4
  isNumber,
5
} from '@nestjs/common/utils/shared.utils';
6
import { MsPattern } from '../interfaces';
7

8
/**
9
 * Transforms the Pattern to Route.
10
 * 1. If Pattern is a `string`, it will be returned as it is.
11
 * 2. If Pattern is a `number`, it will be converted to `string`.
12
 * 3. If Pattern is a `JSON` object, it will be transformed to Route. For that end,
13
 * the function will sort properties of `JSON` Object and creates `route` string
14
 * according to the following template:
15
 * <key1>:<value1>/<key2>:<value2>/.../<keyN>:<valueN>
16
 *
17
 * @param  {MsPattern} pattern - client pattern
18
 * @returns string
19
 */
20
export function transformPatternToRoute(pattern: MsPattern): string {
1✔
21
  if (isString(pattern) || isNumber(pattern)) {
×
22
    return `${pattern}`;
×
23
  }
24
  if (!isObject(pattern)) {
×
25
    return pattern;
×
26
  }
27

28
  const sortedKeys = Object.keys(pattern).sort((a, b) =>
×
29
    ('' + a).localeCompare(b),
×
30
  );
31

32
  // Creates the array of Pattern params from sorted keys and their corresponding values
33
  const sortedPatternParams = sortedKeys.map(key => {
×
34
    let partialRoute = `"${key}":`;
×
35
    partialRoute += isString(pattern[key])
×
36
      ? `"${transformPatternToRoute(pattern[key])}"`
×
37
      : transformPatternToRoute(pattern[key]);
38
    return partialRoute;
×
39
  });
40

41
  const route = sortedPatternParams.join(',');
×
42
  return `{${route}}`;
×
43
}
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