-
-
Notifications
You must be signed in to change notification settings - Fork 153
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
example of how to use GO Feature Flag web provider (#1081)
- Loading branch information
1 parent
9278f91
commit fb1f39a
Showing
23 changed files
with
16,412 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
!goff-proxy.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
# GO Feature Flag web integration | ||
This example shows how to use GO Feature Flag in your web application using the Openfeature web SDK and the GO Feature Flag web provider. | ||
|
||
## How to start the example? | ||
```bash | ||
docker compose up | ||
``` | ||
|
||
It will start `thomaspoignant/go-feature-flag` docker image and build the web application located in the `webapp` directory. | ||
|
||
When ready you can access to the application at http://localhost:3000/. | ||
|
||
## What this example does? | ||
It uses the Openfeature Web SDK and the GO Feature Flag web provider. | ||
|
||
The configuration of the server is in the `goff-proxy.yaml` file and it loads the flag configuration from the `config.goff.yaml` file. | ||
|
||
You can look at the file [`src/js/main.js`](src/js/main.js) to look how we retrieve the flags and we change the display of the page. | ||
|
||
At any moment during the demo you can edit the `config.goff.yaml` file and see how it changes the behaviors of the application. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
badge-title: | ||
variations: | ||
authentified: 'Authenticated' | ||
anonymous: 'Anonymous' | ||
premium: 'Premium User' | ||
targeting: | ||
- query: premium eq true | ||
variation: premium | ||
- query: anonymous eq false | ||
variation: authentified | ||
defaultRule: | ||
variation: anonymous | ||
|
||
beta: | ||
variations: | ||
beta: true | ||
default: false | ||
targeting: | ||
- query: beta eq true | ||
variation: beta | ||
defaultRule: | ||
variation: default |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
version: '3' | ||
services: | ||
gofeatureflag: | ||
image: thomaspoignant/go-feature-flag | ||
ports: | ||
- "1031:1031" | ||
volumes: | ||
- type: bind | ||
source: ./ | ||
target: /goff/ | ||
|
||
webapp: | ||
build: webapp/. | ||
ports: | ||
- "3000:3000" | ||
depends_on: | ||
- gofeatureflag |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
listen: 1031 | ||
pollingInterval: 1000 | ||
retriever: | ||
kind: file | ||
path: /goff/config.goff.yaml |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"presets": ["@babel/preset-env"], | ||
"plugins": [ | ||
"transform-class-properties" | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
npm-debug.log |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es6": true | ||
}, | ||
"extends": "eslint:recommended", | ||
"globals": { | ||
"Atomics": "readonly", | ||
"SharedArrayBuffer": "readonly" | ||
}, | ||
"parser": "@babel/eslint-parser", | ||
"parserOptions": { | ||
"requireConfigFile":false, | ||
"ecmaVersion": 2018, | ||
"sourceType": "module", | ||
"allowImportExportEverywhere": true | ||
}, | ||
"rules": { | ||
"semi": ["error", "always"], | ||
"quotes": ["error", "single"] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
"rules": { | ||
"block-no-empty": true, | ||
"color-hex-length": "short", | ||
"color-no-invalid-hex": true, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
FROM node:20 | ||
WORKDIR /usr/app | ||
COPY . . | ||
RUN npm install && npm run build | ||
CMD ["npm", "run", "serve:docker"] |
Oops, something went wrong.