Skip to content

Commit

Permalink
refactor: add environmental variable for client secret
Browse files Browse the repository at this point in the history
  • Loading branch information
nickybondarenko committed Aug 20, 2024
1 parent 3f7f3b5 commit 4a04aa8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ examples/*/build
examples/*/.next
examples/*/out
examples/*/*.log*
examples/*/.env*
examples/*/*.tsbuildinfo
examples/*/next-env.d.ts
examples/.env

# logs
npm-debug.log*
Expand Down
2 changes: 1 addition & 1 deletion examples/node/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@spotify-confidence/sdk": "workspace:"
},
"scripts": {
"dev": "node src/index.js"
"dev": "node --env-file=../.env src/index.js"
},
"private": true
}
2 changes: 1 addition & 1 deletion examples/node/src/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Confidence } from '@spotify-confidence/sdk';

const confidence = Confidence.create({
clientSecret: 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV',
clientSecret: process.env.CLIENT_SECRET,
fetchImplementation: fetch,
timeout: 1000,
logger: console,
Expand Down
2 changes: 1 addition & 1 deletion examples/nodeCJS/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ async function main() {
const { createConfidenceServerProvider } = await import('@spotify-confidence/openfeature-server-provider');

const provider = createConfidenceServerProvider({
clientSecret: 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV',
clientSecret: process.env.CLIENT_SECRET,
region: 'eu',
fetchImplementation: fetch,
timeout: 1000,
Expand Down
1 change: 1 addition & 0 deletions examples/react18/.env
7 changes: 6 additions & 1 deletion examples/react18/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,13 @@ const handleFailRequestsOnChange = (e: React.ChangeEvent<HTMLInputElement>) => {
state.failRequests = e.target.checked;
};

if (!process.env.REACT_APP_CLIENT_SECRET) {
console.error('REACT_APP_CLIENT_SECRET not set in .env');
process.exit(1);
}

const confidence = Confidence.create({
clientSecret: 'RxDVTrXvc6op1XxiQ4OaR31dKbJ39aYV',
clientSecret: process.env.REACT_APP_CLIENT_SECRET,
environment: 'client',
timeout: 3000,
logger: console,
Expand Down

0 comments on commit 4a04aa8

Please sign in to comment.