Skip to content

Commit 2faca66

Browse files
committed
feature(microservices): add handling of fields with number type
1 parent ff6c46e commit 2faca66

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

packages/microservices/utils/msvc.util.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
import { isString, isObject } from '@nestjs/common/utils/shared.utils';
2+
import * as Interfaces from '../interfaces';
23

34
export class MsvcUtil {
45

56
/**
67
* Transforms the Pattern to Route.
78
* 1. If Pattern is a `string`, it will be returned as it is.
8-
* 2. If Pattern is a `JSON` object, it will be transformed to Route. For that end,
9+
* 2. If Pattern is a `number`, it will be converted to `string`.
10+
* 3. If Pattern is a `JSON` object, it will be transformed to Route. For that end,
911
* the function will sort properties of `JSON` Object and creates `route` string
1012
* according to the following template:
1113
* <key1>:<value1>/<key2>:<value2>/.../<keyN>:<valueN>
@@ -14,9 +16,9 @@ export class MsvcUtil {
1416
* @returns string
1517
*/
1618
public static transformPatternToRoute(pattern: Interfaces.MsPattern): string {
17-
// Returns the pattern according to the 1st
18-
if (isString(pattern)) {
19-
return pattern;
19+
// Returns the pattern according to the 1st and the 2nd points
20+
if (isString(pattern) || typeof pattern === 'number') {
21+
return `${pattern}`;
2022
}
2123

2224
// Throws the error if the pattern has an incorrect type

0 commit comments

Comments
 (0)