@@ -18,6 +18,8 @@ export class Config {
1818 public static tls_passphrase : string = Config . getEnv ( "tls_passphrase" , "" ) ;
1919 public static port : number = parseInt ( Config . getEnv ( "port" , "1880" ) ) ;
2020 public static domain : string = Config . getEnv ( "domain" , "localhost" ) ;
21+ public static nodered_domain_schema : string = Config . getEnv ( "nodered_domain_schema" , "" ) ;
22+
2123 public static api_ws_url : string = Config . getEnv ( "api_ws_url" , "ws://localhost:3000" ) ;
2224 public static amqp_url : string = Config . getEnv ( "amqp_url" , "amqp://localhost" ) ;
2325
@@ -27,6 +29,11 @@ export class Config {
2729 public static aes_secret : string = Config . getEnv ( "aes_secret" , "" ) ;
2830
2931 public static baseurl ( ) : string {
32+ var matches = Config . nodered_id . match ( / \d + / ) ;
33+ Config . nodered_id = matches [ matches . length - 1 ] ; // Just grab the last number
34+ if ( Config . nodered_domain_schema != "" ) {
35+ Config . domain = Config . nodered_domain_schema . replace ( "$nodered_id$" , Config . nodered_id )
36+ }
3037 if ( Config . tls_crt != '' && Config . tls_key != '' ) {
3138 return "https://" + Config . domain + ":" + Config . port + "/" ;
3239 }
@@ -38,8 +45,8 @@ export class Config {
3845 if ( ! value || value === "" ) { value = defaultvalue ; }
3946 return value ;
4047 }
41- public static parseBoolean ( s :any ) :boolean {
42- var val :string = "false" ;
48+ public static parseBoolean ( s : any ) : boolean {
49+ var val : string = "false" ;
4350 if ( typeof s === "number" ) {
4451 val = s . toString ( ) ;
4552 } else if ( typeof s === "string" ) {
@@ -49,7 +56,7 @@ export class Config {
4956 } else {
5057 throw new Error ( "Unknown type!" ) ;
5158 }
52- switch ( val ) {
59+ switch ( val ) {
5360 case "true" : case "yes" : case "1" : return true ;
5461 case "false" : case "no" : case "0" : case null : return false ;
5562 default : return Boolean ( s ) ;
0 commit comments