@@ -2,7 +2,9 @@ import CommunicationProtocolEnum from "../enum/CommunicationProtocol.enum";
2
2
3
3
export class Settings {
4
4
private static readonly defaultHost : string = "127.0.0.1" ;
5
+ private static readonly defaultHttpAppPort : string = "3000" ;
5
6
private static readonly defaultHttpPort : string = "3500" ;
7
+ private static readonly defaultGrpcAppPort : string = "50000" ;
6
8
private static readonly defaultGrpcPort : string = "50001" ;
7
9
8
10
static getDefaultHost ( ) : string {
@@ -17,6 +19,11 @@ export class Settings {
17
19
return process . env . DAPR_GRPC_PORT ?? Settings . defaultGrpcPort ;
18
20
}
19
21
22
+ /**
23
+ * Gets the default port that the Dapr sidecar is listening to.
24
+ * @param communicationProtocolEnum communication protocol
25
+ * @returns port number
26
+ */
20
27
static getDefaultPort ( communicationProtocolEnum : CommunicationProtocolEnum ) : string {
21
28
switch ( communicationProtocolEnum ) {
22
29
case CommunicationProtocolEnum . GRPC :
@@ -25,4 +32,26 @@ export class Settings {
25
32
return this . getDefaultHttpPort ( ) ;
26
33
}
27
34
}
35
+
36
+ static getDefaultHttpAppPort ( ) : string {
37
+ return process . env . APP_PORT ?? Settings . defaultHttpAppPort ;
38
+ }
39
+
40
+ static getDefaultGrpcAppPort ( ) : string {
41
+ return process . env . APP_PORT ?? Settings . defaultGrpcAppPort ;
42
+ }
43
+
44
+ /**
45
+ * Gets the default port that the application is listening on.
46
+ * @param communicationProtocolEnum communication protocol
47
+ * @returns port number
48
+ */
49
+ static getDefaultAppPort ( communicationProtocolEnum : CommunicationProtocolEnum ) : string {
50
+ switch ( communicationProtocolEnum ) {
51
+ case CommunicationProtocolEnum . GRPC :
52
+ return this . getDefaultGrpcAppPort ( ) ;
53
+ default :
54
+ return this . getDefaultHttpAppPort ( ) ;
55
+ }
56
+ }
28
57
}
0 commit comments