Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(onboarding): nodejs snippet for production #8256

Merged
merged 1 commit into from
Sep 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading