Skip to content

Commit

Permalink
refactor: improve Askem api key api config
Browse files Browse the repository at this point in the history
  • Loading branch information
nikomakela authored and karisal-anders committed Nov 6, 2023
1 parent eceb908 commit 47469db
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 21 deletions.
13 changes: 6 additions & 7 deletions apps/events-helsinki/src/domain/app/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,15 @@ class AppConfig {
}

static askemFeedbackConfiguration(locale: 'en' | 'fi' | 'sv') {
const askemApiKeyByLocale: Record<typeof locale, string | undefined> = {
fi: process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI,
sv: process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV,
en: process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN,
};
const askemEnabled = process.env.NEXT_PUBLIC_ASKEM_ENABLED;
let askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI;
if (locale === 'en') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN;
} else if (locale === 'sv') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV;
}
return {
disabled: !parseEnvValue(askemEnabled),
apiKey: askemApiKey as string,
apiKey: askemApiKeyByLocale[locale] ?? '',
};
}

Expand Down
13 changes: 6 additions & 7 deletions apps/hobbies-helsinki/src/domain/app/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,16 +173,15 @@ class AppConfig {
}

static askemFeedbackConfiguration(locale: 'en' | 'fi' | 'sv') {
const askemApiKeyByLocale: Record<typeof locale, string | undefined> = {
fi: process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI,
sv: process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV,
en: process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN,
};
const askemEnabled = process.env.NEXT_PUBLIC_ASKEM_ENABLED;
let askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI;
if (locale === 'en') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN;
} else if (locale === 'sv') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV;
}
return {
disabled: !parseEnvValue(askemEnabled),
apiKey: askemApiKey as string,
apiKey: askemApiKeyByLocale[locale] ?? '',
};
}

Expand Down
13 changes: 6 additions & 7 deletions apps/sports-helsinki/src/domain/app/AppConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -172,16 +172,15 @@ class AppConfig {
}

static askemFeedbackConfiguration(locale: 'en' | 'fi' | 'sv') {
const askemApiKeyByLocale: Record<typeof locale, string | undefined> = {
fi: process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI,
sv: process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV,
en: process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN,
};
const askemEnabled = process.env.NEXT_PUBLIC_ASKEM_ENABLED;
let askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_FI;
if (locale === 'en') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_EN;
} else if (locale === 'sv') {
askemApiKey = process.env.NEXT_PUBLIC_ASKEM_API_KEY_SV;
}
return {
disabled: !parseEnvValue(askemEnabled),
apiKey: askemApiKey as string,
apiKey: askemApiKeyByLocale[locale] ?? '',
};
}

Expand Down

0 comments on commit 47469db

Please sign in to comment.