11import {
22 getEnvOrError ,
3+ getRuntimeEnv ,
34 EventTypeId ,
45 ignoredErrorCodesHeader ,
56} from '@events-helsinki/components' ;
@@ -24,7 +25,10 @@ class AppConfig {
2425 * inside the app.
2526 * */
2627 static get cmsOrigin ( ) {
27- return getEnvOrError ( publicRuntimeConfig . cmsOrigin , 'CMS_ORIGIN' ) ;
28+ return getEnvOrError (
29+ getRuntimeEnv ( 'CMS_ORIGIN' ) ?? publicRuntimeConfig . cmsOrigin ,
30+ 'CMS_ORIGIN'
31+ ) ;
2832 }
2933
3034 /**
@@ -33,7 +37,8 @@ class AppConfig {
3337 * */
3438 static get federationGraphqlEndpoint ( ) {
3539 return getEnvOrError (
36- publicRuntimeConfig . federationRouter ,
40+ getRuntimeEnv ( 'FEDERATION_ROUTER_ENDPOINT' ) ??
41+ publicRuntimeConfig . federationRouter ,
3742 'FEDERATION_ROUTER_ENDPOINT'
3843 ) ;
3944 }
@@ -49,7 +54,8 @@ class AppConfig {
4954 * */
5055 static get linkedEventsEventEndpoint ( ) {
5156 return getEnvOrError (
52- publicRuntimeConfig . linkedEvents ,
57+ getRuntimeEnv ( 'LINKEDEVENTS_EVENT_ENDPOINT' ) ??
58+ publicRuntimeConfig . linkedEvents ,
5359 'LINKEDEVENTS_EVENT_ENDPOINT'
5460 ) ;
5561 }
@@ -60,7 +66,7 @@ class AppConfig {
6066 * */
6167 static get origin ( ) {
6268 return getEnvOrError (
63- process . env . NEXT_PUBLIC_APP_ORIGIN ,
69+ getRuntimeEnv ( ' NEXT_PUBLIC_APP_ORIGIN' ) ,
6470 'NEXT_PUBLIC_APP_ORIGIN'
6571 ) ;
6672 }
@@ -81,7 +87,9 @@ class AppConfig {
8187 * The application can then use a PostQuery to fetch the related information from an external service.
8288 */
8389 static get cmsArticlesContextPath ( ) {
84- return process . env . NEXT_PUBLIC_CMS_ARTICLES_CONTEXT_PATH ?? '/articles' ;
90+ return (
91+ getRuntimeEnv ( 'NEXT_PUBLIC_CMS_ARTICLES_CONTEXT_PATH' ) ?? '/articles'
92+ ) ;
8593 }
8694
8795 /**
@@ -93,7 +101,7 @@ class AppConfig {
93101 * The application can then use a PageQuery to fetch the related information from an external service.
94102 */
95103 static get cmsPagesContextPath ( ) {
96- return process . env . NEXT_PUBLIC_CMS_PAGES_CONTEXT_PATH ?? '/pages' ;
104+ return getRuntimeEnv ( ' NEXT_PUBLIC_CMS_PAGES_CONTEXT_PATH' ) ?? '/pages' ;
97105 }
98106
99107 /** The supported LinkedEvent event types. */
@@ -131,13 +139,13 @@ class AppConfig {
131139 /** Should the application allow HTTP-connections? */
132140 static get allowUnauthorizedRequests ( ) {
133141 return Boolean (
134- parseEnvValue ( process . env . NEXT_PUBLIC_ALLOW_UNAUTHORIZED_REQUESTS )
142+ parseEnvValue ( getRuntimeEnv ( ' NEXT_PUBLIC_ALLOW_UNAUTHORIZED_REQUESTS' ) )
135143 ) ;
136144 }
137145
138146 /** A global debug switch for development purposes. */
139147 static get debug ( ) {
140- return Boolean ( parseEnvValue ( process . env . NEXT_PUBLIC_DEBUG ) ) ;
148+ return Boolean ( parseEnvValue ( getRuntimeEnv ( ' NEXT_PUBLIC_DEBUG' ) ) ) ;
141149 }
142150
143151 /** A default HDS theme for the buttons. https://hds.hel.fi/foundation/design-tokens/colour. */
@@ -151,31 +159,31 @@ class AppConfig {
151159 > = ButtonVariant . Success ;
152160
153161 static get matomoConfiguration ( ) {
154- const matomoUrlBase = process . env . NEXT_PUBLIC_MATOMO_URL_BASE ;
155- const matomoEnabled = process . env . NEXT_PUBLIC_MATOMO_ENABLED ;
156- const matomoSiteId = process . env . NEXT_PUBLIC_MATOMO_SITE_ID ;
162+ const matomoUrlBase = getRuntimeEnv ( ' NEXT_PUBLIC_MATOMO_URL_BASE' ) ;
163+ const matomoEnabled = getRuntimeEnv ( ' NEXT_PUBLIC_MATOMO_ENABLED' ) ;
164+ const matomoSiteId = getRuntimeEnv ( ' NEXT_PUBLIC_MATOMO_SITE_ID' ) ;
157165 const getMatomoUrlPath = ( path : string ) => `${ matomoUrlBase } ${ path } ` ;
158166
159167 return {
160168 disabled : ! parseEnvValue ( matomoEnabled ) ,
161169 urlBase : matomoUrlBase as string ,
162170 srcUrl : getMatomoUrlPath (
163- process . env . NEXT_PUBLIC_MATOMO_SRC_URL as string
171+ getRuntimeEnv ( ' NEXT_PUBLIC_MATOMO_SRC_URL' ) as string
164172 ) ,
165173 trackerUrl : getMatomoUrlPath (
166- process . env . NEXT_PUBLIC_MATOMO_TRACKER_URL as string
174+ getRuntimeEnv ( ' NEXT_PUBLIC_MATOMO_TRACKER_URL' ) as string
167175 ) ,
168176 siteId : Number ( matomoSiteId ) ,
169177 } ;
170178 }
171179
172180 static askemFeedbackConfiguration ( locale : 'en' | 'fi' | 'sv' ) {
173181 const askemApiKeyByLocale : Record < typeof locale , string | undefined > = {
174- fi : process . env . NEXT_PUBLIC_ASKEM_API_KEY_FI ,
175- sv : process . env . NEXT_PUBLIC_ASKEM_API_KEY_SV ,
176- en : process . env . NEXT_PUBLIC_ASKEM_API_KEY_EN ,
182+ fi : getRuntimeEnv ( ' NEXT_PUBLIC_ASKEM_API_KEY_FI' ) ,
183+ sv : getRuntimeEnv ( ' NEXT_PUBLIC_ASKEM_API_KEY_SV' ) ,
184+ en : getRuntimeEnv ( ' NEXT_PUBLIC_ASKEM_API_KEY_EN' ) ,
177185 } ;
178- const askemEnabled = process . env . NEXT_PUBLIC_ASKEM_ENABLED ;
186+ const askemEnabled = getRuntimeEnv ( ' NEXT_PUBLIC_ASKEM_ENABLED' ) ;
179187 return {
180188 disabled : ! parseEnvValue ( askemEnabled ) ,
181189 apiKey : askemApiKeyByLocale [ locale ] ?? '' ,
@@ -188,7 +196,9 @@ class AppConfig {
188196 * #on-demand-revalidation
189197 */
190198 static get defaultRevalidate ( ) {
191- const envValue = process . env . NEXT_PUBLIC_DEFAULT_ISR_REVALIDATE_SECONDS ;
199+ const envValue = getRuntimeEnv (
200+ 'NEXT_PUBLIC_DEFAULT_ISR_REVALIDATE_SECONDS'
201+ ) ;
192202 const value = envValue ? parseEnvValue ( envValue ) : 60 ;
193203
194204 if ( typeof value !== 'number' ) {
@@ -224,22 +234,22 @@ class AppConfig {
224234 */
225235 static get skipBuildStaticGeneration ( ) {
226236 return Boolean (
227- parseEnvValue ( process . env . SKIP_BUILD_STATIC_GENERATION , false )
237+ parseEnvValue ( getRuntimeEnv ( ' SKIP_BUILD_STATIC_GENERATION' ) , false )
228238 ) ;
229239 }
230240
231241 /** A feature flag for the similar events. */
232242 static get showSimilarEvents ( ) {
233243 return Boolean (
234- parseEnvValue ( process . env . NEXT_PUBLIC_SHOW_SIMILAR_EVENTS , true )
244+ parseEnvValue ( getRuntimeEnv ( ' NEXT_PUBLIC_SHOW_SIMILAR_EVENTS' ) , true )
235245 ) ;
236246 }
237247
238248 /** A feature flag that can be used to show the enrolment status in the card details. */
239249 static get showEnrolmentStatusInCardDetails ( ) {
240250 return Boolean (
241251 parseEnvValue (
242- process . env . NEXT_PUBLIC_SHOW_ENROLMENT_STATUS_IN_CARD_DETAILS ,
252+ getRuntimeEnv ( ' NEXT_PUBLIC_SHOW_ENROLMENT_STATUS_IN_CARD_DETAILS' ) ,
243253 false
244254 )
245255 ) ;
0 commit comments