Skip to content

Commit 4b34f79

Browse files
move readme and license (#37)
1 parent fe42395 commit 4b34f79

File tree

2 files changed

+105
-0
lines changed

2 files changed

+105
-0
lines changed

sdk/feature-management/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) Microsoft Corporation.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE

sdk/feature-management/README.md

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,84 @@
1+
# Microsoft Feature Management for JavaScript
2+
3+
[![feature-management](https://img.shields.io/npm/v/@microsoft/feature-management?label=@microsoft/feature-management)](https://www.npmjs.com/package/@microsoft/feature-management)
4+
5+
Feature Management is a library for enabling/disabling features at runtime.
6+
Developers can use feature flags in simple use cases like conditional statement to more advanced scenarios like conditionally adding routes.
7+
8+
## Getting Started
9+
10+
### Prerequisites
11+
12+
- Node.js LTS version
13+
14+
### Usage
15+
16+
You can use feature flags from the Azure App Configuration service, local files or any other sources.
17+
18+
#### Use feature flags from Azure App Configuration
19+
20+
The App Configuration JavaScript provider provides feature flags in as a `Map` object.
21+
A builtin `ConfigurationMapFeatureFlagProvider` helps to load feature flags in this case.
22+
23+
```js
24+
const appConfig = load(connectionString, {featureFlagOptions}); // load feature flags from Azure App Configuration service
25+
const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig);
26+
const featureManager = new FeatureManager(featureProvider);
27+
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
28+
console.log("Feature Alpha is:", isAlphaEnabled);
29+
```
30+
31+
#### Use feature flags from a json file
32+
33+
A sample JSON file with the following format can be used to load feature flags.
34+
The JSON file can be read and parsed as an object as a whole.
35+
A builtin `ConfigurationObjectFeatureFlagProvider` helps to load feature flags in this case.
36+
37+
Content of `sample.json`:
38+
```json
39+
{
40+
"feature_management": {
41+
"feature_flags": [
42+
{
43+
"id": "Alpha",
44+
"description": "",
45+
"enabled": "true",
46+
"conditions": {
47+
"client_filters": []
48+
}
49+
}
50+
]
51+
}
52+
}
53+
```
54+
55+
Load feature flags from `sample.json` file.
56+
```js
57+
const config = JSON.parse(await fs.readFile("path/to/sample.json"));
58+
const featureProvider = new ConfigurationObjectFeatureFlagProvider(config);
59+
const featureManager = new FeatureManager(featureProvider);
60+
const isAlphaEnabled = await featureManager.isEnabled("Alpha");
61+
console.log("Feature Alpha is:", isAlphaEnabled);
62+
```
63+
64+
## Contributing
65+
66+
This project welcomes contributions and suggestions. Most contributions require you to agree to a
67+
Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
68+
the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
69+
70+
When you submit a pull request, a CLA bot will automatically determine whether you need to provide
71+
a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
72+
provided by the bot. You will only need to do this once across all repos using our CLA.
73+
74+
This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
75+
For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
76+
contact [[email protected]](mailto:[email protected]) with any additional questions or comments.
77+
78+
## Trademarks
79+
80+
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
81+
trademarks or logos is subject to and must follow
82+
[Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
83+
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
84+
Any use of third-party trademarks or logos are subject to those third-party's policies.

0 commit comments

Comments
 (0)