From c7427f4b91acec65475a648e68c1f168e3f19171 Mon Sep 17 00:00:00 2001 From: Tymoteusz Czech <2625371+Tymek@users.noreply.github.com> Date: Wed, 25 Sep 2024 15:45:53 +0200 Subject: [PATCH] feat(onboarding): nodejs snippet for production (#8256) --- .../component/onboarding/TestSdkConnection.tsx | 4 +++- .../component/onboarding/snippets/nodejs.md | 18 ++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/frontend/src/component/onboarding/TestSdkConnection.tsx b/frontend/src/component/onboarding/TestSdkConnection.tsx index 892ade544e53..dab000d04800 100644 --- a/frontend/src/component/onboarding/TestSdkConnection.tsx +++ b/frontend/src/component/onboarding/TestSdkConnection.tsx @@ -141,6 +141,8 @@ export const TestSdkConnection: FC = ({ .replace('', apiKey) .replace('', apiUrl) .replaceAll('', feature); + const [connectSnippet, _productionSnippet, _otherResourcesSnippet] = + snippet.split('---\n'); return ( @@ -164,7 +166,7 @@ export const TestSdkConnection: FC = ({ Setup the SDK - {snippet} + {connectSnippet} diff --git a/frontend/src/component/onboarding/snippets/nodejs.md b/frontend/src/component/onboarding/snippets/nodejs.md index e7fbae1f7908..b01f88de824e 100644 --- a/frontend/src/component/onboarding/snippets/nodejs.md +++ b/frontend/src/component/onboarding/snippets/nodejs.md @@ -21,3 +21,21 @@ setInterval(() => { console.log('Is enabled', unleash.isEnabled('')); }, 1000); ``` + +--- +```js +const { UnleashClient } = require('unleash-proxy-client'); + +const unleash = new UnleashClient({ + 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)