@@ -32,6 +32,7 @@ function removeTrailingSlash(str) {
32
32
return str ;
33
33
}
34
34
35
+ const asyncKeys = [ 'publicServerURL' ] ;
35
36
export class Config {
36
37
static get ( applicationId : string , mount : string ) {
37
38
const cacheInfo = AppCache . get ( applicationId ) ;
@@ -56,9 +57,33 @@ export class Config {
56
57
return config ;
57
58
}
58
59
60
+ async loadKeys ( ) {
61
+ const asyncKeys = [ 'publicServerURL' ] ;
62
+
63
+ await Promise . all (
64
+ asyncKeys . map ( async key => {
65
+ if ( typeof this [ `_${ key } ` ] === 'function' ) {
66
+ this [ key ] = await this [ `_${ key } ` ] ( ) ;
67
+ }
68
+ } )
69
+ ) ;
70
+
71
+ Config . put ( this ) ;
72
+ }
73
+
74
+ static transformConfiguration ( serverConfiguration ) {
75
+ for ( const key of Object . keys ( serverConfiguration ) ) {
76
+ if ( asyncKeys . includes ( key ) && typeof serverConfiguration [ key ] === 'function' ) {
77
+ serverConfiguration [ `_${ key } ` ] = serverConfiguration [ key ] ;
78
+ delete serverConfiguration [ key ] ;
79
+ }
80
+ }
81
+ }
82
+
59
83
static put ( serverConfiguration ) {
60
84
Config . validateOptions ( serverConfiguration ) ;
61
85
Config . validateControllers ( serverConfiguration ) ;
86
+ Config . transformConfiguration ( serverConfiguration ) ;
62
87
AppCache . put ( serverConfiguration . appId , serverConfiguration ) ;
63
88
Config . setupPasswordValidator ( serverConfiguration . passwordPolicy ) ;
64
89
return serverConfiguration ;
@@ -116,7 +141,11 @@ export class Config {
116
141
}
117
142
118
143
if ( publicServerURL ) {
119
- if ( ! publicServerURL . startsWith ( 'http://' ) && ! publicServerURL . startsWith ( 'https://' ) ) {
144
+ if (
145
+ typeof publicServerURL !== 'function' &&
146
+ ! publicServerURL . startsWith ( 'http://' ) &&
147
+ ! publicServerURL . startsWith ( 'https://' )
148
+ ) {
120
149
throw 'publicServerURL should be a valid HTTPS URL starting with https://' ;
121
150
}
122
151
}
@@ -757,7 +786,6 @@ export class Config {
757
786
return this . masterKey ;
758
787
}
759
788
760
-
761
789
// TODO: Remove this function once PagesRouter replaces the PublicAPIRouter;
762
790
// the (default) endpoint has to be defined in PagesRouter only.
763
791
get pagesEndpoint ( ) {
0 commit comments