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

Commit

Permalink
Wrap unleash in error
Browse files Browse the repository at this point in the history
  • Loading branch information
terjeofnorway committed Oct 7, 2023
1 parent 521cf5d commit 1a127b0
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/server/api-handlers/features.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,17 @@ const initializeUnleash = async () => {
return false;
}

unleashInstance = initialize({
url: UNLEASH_SERVER_API_URL,
appName: 'nav-dekoratoren',
customHeaders: { Authorization: UNLEASH_SERVER_API_TOKEN },
});

console.log(unleashInstance.isSynchronized() ? 'Unleash is synchronized' : 'Unleash is not synchronized');
try {
unleashInstance = initialize({
url: UNLEASH_SERVER_API_URL,
appName: 'nav-dekoratoren',
customHeaders: { Authorization: UNLEASH_SERVER_API_TOKEN },
});

console.log(unleashInstance.isSynchronized() ? 'Unleash is synchronized' : 'Unleash is not synchronized');
} catch (e) {
console.error('Error initializing unleash', e);
}

return true;
};
Expand All @@ -25,7 +29,7 @@ export const getFeaturesHandler: RequestHandler = async (req, res) => {
// so just mock this.

if (!unleashInstance) {
initializeUnleash();
await initializeUnleash();
}

// res.status(500).send('Missing UNLEASH_SERVER_API_TOKEN or UNLEASH_SERVER_API_URL');
Expand Down

0 comments on commit 1a127b0

Please sign in to comment.