Skip to content

Commit 9d6cb86

Browse files
james-milliganbeeme1mrthomaspoignanttoddbaert
authored
feat: flagd provider (open-feature#66)
* initial commit Signed-off-by: James-Milligan <[email protected]> * nx format:write Signed-off-by: James-Milligan <[email protected]> * udpated nxignore to exclude generated files Signed-off-by: James-Milligan <[email protected]> * fixed linting issues Signed-off-by: James-Milligan <[email protected]> * typo Signed-off-by: James-Milligan <[email protected]> * removed nested .vscode Signed-off-by: James-Milligan <[email protected]> * added typing to axios response objects Signed-off-by: James-Milligan <[email protected]> * removed proto files from version control Signed-off-by: James-Milligan <[email protected]> * required commit for nx run-command Signed-off-by: James-Milligan <[email protected]> * actions Signed-off-by: James-Milligan <[email protected]> * dependency updates + removal of cantextTransformer method Signed-off-by: James-Milligan <[email protected]> * removed forked submodule Signed-off-by: James-Milligan <[email protected]> * switched to open-feature/schemas Signed-off-by: James-Milligan <[email protected]> * dependency sync Signed-off-by: James-Milligan <[email protected]> * merge fixes Signed-off-by: James-Milligan <[email protected]> * workspace fixes Signed-off-by: James-Milligan <[email protected]> * merge fixes Signed-off-by: James-Milligan <[email protected]> * merge fixes Signed-off-by: James-Milligan <[email protected]> * merge fixes - added go to ci Signed-off-by: James-Milligan <[email protected]> * merge fixes Signed-off-by: James-Milligan <[email protected]> * updated go version in github action setup Signed-off-by: James-Milligan <[email protected]> * squashed commits Signed-off-by: James-Milligan <[email protected]> * buf setup test => avoid using go install buf Signed-off-by: James-Milligan <[email protected]> * removed go setup + removed submodule issue => error Signed-off-by: James-Milligan <[email protected]> * removed go setup + removed submodule issue => error Signed-off-by: James-Milligan <[email protected]> * happy path unit tests Signed-off-by: James-Milligan <[email protected]> * more unit tests + fixes Signed-off-by: James-Milligan <[email protected]> * set noImplicitOverride to false Signed-off-by: James-Milligan <[email protected]> * errorCode consolidation Signed-off-by: James-Milligan <[email protected]> * removed tslint ignores and .vscode files Signed-off-by: James-Milligan <[email protected]> * package.json cleanup Signed-off-by: James-Milligan <[email protected]> * Update project.json Signed-off-by: James Milligan <[email protected]> * Apply suggestions from code review Co-authored-by: Michael Beemer <[email protected]> Signed-off-by: James Milligan <[email protected]> * PR updates Signed-off-by: James-Milligan <[email protected]> * removed makefile Signed-off-by: James-Milligan <[email protected]> * replaced hardcoded errorCode and reason values with imported values from nodesdk Signed-off-by: James-Milligan <[email protected]> * style updates, simplification of provider construction, README updates Signed-off-by: James-Milligan <[email protected]> * removed variant value "default_value" on error/default, simplified checkResponse function Signed-off-by: James-Milligan <[email protected]> * Update README.md Signed-off-by: James Milligan <[email protected]> * Update libs/providers/flagd/package.json Co-authored-by: Thomas Poignant <[email protected]> Signed-off-by: James Milligan <[email protected]> * added encodeURI to urls in http service Signed-off-by: James-Milligan <[email protected]> * Update pushlish script Signed-off-by: Todd Baert <[email protected]> * encodeURIComponent(flagKey) in http service Signed-off-by: James-Milligan <[email protected]> * added protocol option Signed-off-by: James-Milligan <[email protected]> * update README Signed-off-by: James-Milligan <[email protected]> Co-authored-by: Michael Beemer <[email protected]> Co-authored-by: Thomas Poignant <[email protected]> Co-authored-by: Todd Baert <[email protected]>
1 parent 7db7d31 commit 9d6cb86

28 files changed

+1720
-59
lines changed

.github/workflows/ci.yml

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ jobs:
1212
- uses: actions/checkout@v2
1313
with:
1414
fetch-depth: 0
15+
- uses: bufbuild/[email protected]
16+
with:
17+
version: '1.1.1'
1518
- uses: nrwl/nx-set-shas@v2
1619
- run: npm ci
1720

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,6 @@ testem.log
3737
# System Files
3838
.DS_Store
3939
Thumbs.db
40+
41+
# generated files
42+
proto

.gitmodules

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "libs/providers/flagd/schemas"]
2+
path = libs/providers/flagd/schemas
3+
url = https://github.com/open-feature/schemas

.release-please-manifest.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
{
22
"libs/hooks/open-telemetry": "1.2.3-alpha",
3-
"libs/providers/go-feature-flag": "0.1.3"
4-
}
3+
"libs/providers/go-feature-flag": "0.1.3",
4+
"libs/providers/flagd": "0.1.0"
5+
}

.vscode/extensions.json

-8
This file was deleted.

libs/providers/flagd/.babelrc

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
{
2+
"presets": [
3+
[
4+
"@nrwl/web/babel",
5+
{
6+
"useBuiltIns": "usage"
7+
}
8+
]
9+
]
10+
}

libs/providers/flagd/.eslintrc.json

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"extends": ["../../../.eslintrc.json"],
3+
"ignorePatterns": ["!**/*", "node_modules", "src/proto/**"],
4+
"overrides": [
5+
{
6+
"files": ["*.ts", "*.tsx", "*.js", "*.jsx"],
7+
"rules": {}
8+
},
9+
{
10+
"files": ["*.ts", "*.tsx"],
11+
"rules": {}
12+
},
13+
{
14+
"files": ["*.js", "*.jsx"],
15+
"rules": {}
16+
}
17+
]
18+
}

libs/providers/flagd/README.md

+35
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# NodeJS flagd Provider for OpenFeature
2+
3+
![Experimental](https://img.shields.io/badge/experimental-breaking%20changes%20allowed-yellow)
4+
5+
Flagd is a simple command line tool for fetching and presenting feature flags to services. It is designed to conform to OpenFeature schema for flag definitions. This repository and package provides the client side code for interacting with it via the Open-Feature Node SDK.
6+
7+
## Installation
8+
9+
```
10+
$ npm install @openfeature/flagd-provider
11+
```
12+
13+
## Building
14+
15+
Run `nx package providers-flagd` to build the library.
16+
17+
## Running unit tests
18+
19+
Run `nx test providers-flagd` to execute the unit tests via [Jest](https://jestjs.io).
20+
21+
22+
## Usage
23+
24+
The `FlagdProvider` client constructor takes a single optional argument with 3 fields, their default values correspond to the default arguments supplied to the flagd server:
25+
```
26+
OpenFeature.setProvider(new FlagdProvider({
27+
service: 'grpc',
28+
host: 'localhost',
29+
port: 8080,
30+
}))
31+
```
32+
**service**: "http" | "grpc" *(defaults to http)*
33+
**host**: string *(defaults to "localhost")*
34+
**port**: number *(defaults to 8080)*
35+
**protocol**: "http" | "https" *(defaults to http - only active for http service)*
+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"presets": ["minify"]
3+
}

libs/providers/flagd/jest.config.ts

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/* eslint-disable */
2+
export default {
3+
displayName: 'providers-flagd',
4+
preset: '../../../jest.preset.js',
5+
globals: {
6+
'ts-jest': {
7+
tsconfig: '<rootDir>/tsconfig.spec.json',
8+
},
9+
},
10+
transform: {
11+
'^.+\\.[tj]s$': 'ts-jest',
12+
},
13+
moduleFileExtensions: ['ts', 'js', 'html'],
14+
coverageDirectory: '../../../coverage/libs/providers/flagd',
15+
};

0 commit comments

Comments
 (0)