Skip to content
This repository has been archived by the owner on Sep 18, 2024. It is now read-only.

Commit

Permalink
Wrap unleash-klient inn i try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeofnorway committed Oct 6, 2023
1 parent 7d32851 commit 9444afc
Showing 1 changed file with 14 additions and 9 deletions.
23 changes: 14 additions & 9 deletions src/server/api-handlers/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,19 @@ export const getFeaturesHandler: RequestHandler = async (req, res) => {
return;
}

const unleash = await startUnleash({
url: UNLEASH_SERVER_API_URL,
appName: 'nav-dekoratoren',
customHeaders: { Authorization: UNLEASH_SERVER_API_TOKEN },
});
try {
const unleash = await startUnleash({
url: UNLEASH_SERVER_API_URL,
appName: 'nav-dekoratoren',
customHeaders: { Authorization: UNLEASH_SERVER_API_TOKEN },
});

return {
skjermdeling: unleash.isEnabled('dekoratoren.skjermdeling'),
chatbotscript: unleash.isEnabled('dekoratoren.chatbotscript'),
};
return {
skjermdeling: unleash.isEnabled('dekoratoren.skjermdeling'),
chatbotscript: unleash.isEnabled('dekoratoren.chatbotscript'),
};
} catch (e) {
console.error(`Failed to fetch feature toggles from unleash - ${e}`);
res.status(500).send(`Failed to fetch feature toggles from unleash - ${e}`);
}
};

0 comments on commit 9444afc

Please sign in to comment.