diff --git a/README.md b/README.md index 5cd7cec..4b86de7 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,63 @@ -# Project +# Microsoft Feature Management for JavaScript -> This repo has been populated by an initial template to help get you started. Please -> make sure to update the content to build a great experience for community-building. +Feature Management is a library for enabling/disabling features at runtime. +Developers can use feature flags in simple use cases like conditional statement to more advanced scenarios like conditionally adding routes. -As the maintainer of this project, please make a few updates: +## Getting Started -- Improving this README.MD file to provide a great experience -- Updating SUPPORT.MD with content about this project's support experience -- Understanding the security reporting process in SECURITY.MD -- Remove this section from the README +### Prerequisites + +- Node.js LTS version + +### Usage + +You can use feature flags from the Azure App Configuration service, local files or any other sources. + +#### Use feature flags from Azure App Configuration + +The App Configuration JavaScript provider provides feature flags in as a `Map` object. +A builtin `ConfigurationMapFeatureFlagProvider` helps to load feature flags in this case. + +```js +const appConfig = load(connectionString, {featureFlagOptions}); // load feature flags from Azure App Configuration service +const featureProvider = new ConfigurationMapFeatureFlagProvider(appConfig); +const featureManager = new FeatureManager(featureProvider); +const isAlphaEnabled = await featureManager.isEnabled("Alpha"); +console.log("Feature Alpha is:", isAlphaEnabled); +``` + +#### Use feature flags from a json file + +A sample JSON file with the following format can be used to load feature flags. +The JSON file can be read and parsed as an object as a whole. +A builtin `ConfigurationObjectFeatureFlagProvider` helps to load feature flags in this case. + +Content of `sample.json`: +```json +{ + "feature_management": { + "feature_flags": [ + { + "id": "Alpha", + "description": "", + "enabled": "true", + "conditions": { + "client_filters": [] + } + } + ] + } +} +``` + +Load feature flags from `sample.json` file. +```js +const config = JSON.parse(await fs.readFile("path/to/sample.json")); +const featureProvider = new ConfigurationObjectFeatureFlagProvider(config); +const featureManager = new FeatureManager(featureProvider); +const isAlphaEnabled = await featureManager.isEnabled("Alpha"); +console.log("Feature Alpha is:", isAlphaEnabled); +``` ## Contributing diff --git a/SUPPORT.md b/SUPPORT.md index 291d4d4..f176f1a 100644 --- a/SUPPORT.md +++ b/SUPPORT.md @@ -1,25 +1,11 @@ -# TODO: The maintainer of this repo has not yet edited this file - -**REPO OWNER**: Do you want Customer Service & Support (CSS) support for this product/project? - -- **No CSS support:** Fill out this template with information about how to file issues and get help. -- **Yes CSS support:** Fill out an intake form at [aka.ms/onboardsupport](https://aka.ms/onboardsupport). CSS will work with/help you to determine next steps. -- **Not sure?** Fill out an intake as though the answer were "Yes". CSS will help you decide. - -*Then remove this first heading from this SUPPORT.MD file before publishing your repo.* - # Support -## How to file issues and get help +## How to file issues and get help This project uses GitHub Issues to track bugs and feature requests. Please search the existing issues before filing new issues to avoid duplicates. For new issues, file your bug or feature request as a new Issue. -For help and questions about using this project, please **REPO MAINTAINER: INSERT INSTRUCTIONS HERE -FOR HOW TO ENGAGE REPO OWNERS OR COMMUNITY FOR HELP. COULD BE A STACK OVERFLOW TAG OR OTHER -CHANNEL. WHERE WILL YOU HELP PEOPLE?**. - -## Microsoft Support Policy +## Microsoft Support Policy -Support for this **PROJECT or PRODUCT** is limited to the resources listed above. +Support for this project is limited to the resources listed above.