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

nestjs / nest / e1a120dc-6519-4c6a-a074-de38a9ffd346

14 Feb 2025 09:25PM UTC coverage: 27.513% (-61.8%) from 89.294%
e1a120dc-6519-4c6a-a074-de38a9ffd346

Pull #14640

circleci

luddwichr
fix(platform-express) respect existing parser middlewares when using Express 5

Express 5 made the router public API again and renamed the field from app._router to app.router.
This broke the detection mechanism whether a middleware named "jsonParser" or "urlencodedParser"
is already registered or not.
Unfortunately, https://github.com/nestjs/nest/pull/14574/ only fixed the issue partially.
This commit now uses app.router everywhere.
To avoid future regressions a test was added to verify the expected behavior.
Pull Request #14640: fix(platform-express) respect custom parser middlewares in Express 5

250 of 3354 branches covered (7.45%)

2201 of 8000 relevant lines covered (27.51%)

0.57 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