Skip to content

Commit

Permalink
feat(onboarding): nodejs snippet for production
Browse files Browse the repository at this point in the history
  • Loading branch information
Tymek committed Sep 25, 2024
1 parent a95c8d1 commit 05bba61
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
4 changes: 3 additions & 1 deletion frontend/src/component/onboarding/TestSdkConnection.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ export const TestSdkConnection: FC<ITestSdkConnectionProps> = ({
.replace('<YOUR_API_TOKEN>', apiKey)
.replace('<YOUR_API_URL>', apiUrl)
.replaceAll('<YOUR_FLAG>', feature);
const [connectSnippet, _productionSnippet, _otherResourcesSnippet] =
snippet.split('---\n');

return (
<SpacedContainer>
Expand All @@ -164,7 +166,7 @@ export const TestSdkConnection: FC<ITestSdkConnectionProps> = ({
</ChangeSdk>
<SectionHeader>Setup the SDK</SectionHeader>
<Markdown components={{ code: CodeRenderer }}>
{snippet}
{connectSnippet}
</Markdown>
</Box>
</SpacedContainer>
Expand Down
18 changes: 18 additions & 0 deletions frontend/src/component/onboarding/snippets/nodejs.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,21 @@ setInterval(() => {
console.log('Is enabled', unleash.isEnabled('<YOUR_FLAG>'));
}, 1000);
```

---
```js
const { UnleashClient } = require('unleash-proxy-client');

const unleash = new UnleashClient({
url: '<YOUR_API_URL>',
appName: 'unleash-onboarding-node',
customHeaders: { Authorization: process.env.UNLEASH_API_KEY },
});

unleash.start();
```

---
- [SDK repository with documentation](https://github.com/Unleash/unleash-client-node)
- [Node.js SDK example with CodeSandbox](https://github.com/Unleash/unleash-sdk-examples/tree/main/JavaScript)
- [Node.js SDK tutorial](https://dev.to/reeshee/how-to-implement-feature-flags-in-nodejs-using-unleash-3907)

0 comments on commit 05bba61

Please sign in to comment.