1+ // Copyright (c) Microsoft Corporation.
2+ // Licensed under the MIT license.
3+
14import express from "express" ;
2- import path from "path" ;
35
46import { load } from "@azure/app-configuration-provider" ;
5- const connectionString = "<your-connection-string>" ; ;
7+ const connectionString = "<your-connection-string>" ;
68const appConfig = await load ( connectionString , {
79 featureFlagOptions : {
810 enabled : true ,
@@ -25,6 +27,7 @@ import { ConfigurationObjectFeatureFlagProvider, ConfigurationMapFeatureFlagProv
2527You can use either ConfigurationObjectFeatureFlagProvider or ConfigurationMapFeatureFlagProvider to provide feature flags.
2628We recommend using Azure App Configuration as the source of feature flags.
2729*/
30+ // import path from "path";
2831// const config = JSON.parse(await fs.readFile("config.json"));
2932// const featureProvider = new ConfigurationObjectFeatureFlagProvider(config);
3033
@@ -36,19 +39,17 @@ const PORT = 3000;
3639
3740// Use a middleware to achieve request-driven configuration refresh
3841server . use ( ( req , res , next ) => {
39- // this call s not blocking, the configuration will be updated asynchronously
42+ // this call is not blocking, the configuration will be updated asynchronously
4043 appConfig . refresh ( ) ;
4144 next ( ) ;
4245} )
4346
4447
4548server . get ( "/" , ( req , res ) => {
46- appConfig . refresh ( ) ;
4749 res . send ( "Hello World!" ) ;
4850} ) ;
4951
5052server . get ( "/Beta" , async ( req , res ) => {
51- appConfig . refresh ( ) ;
5253 const { userId, groups } = req . query ;
5354
5455 if ( await featureManager . isEnabled ( "Beta" , { userId : userId , groups : groups ? groups . split ( "," ) : [ ] } ) ) {
@@ -61,4 +62,4 @@ server.get("/Beta", async (req, res) => {
6162// Start the server
6263server . listen ( PORT , ( ) => {
6364 console . log ( `Server is running at http://localhost:${ PORT } ` ) ;
64- } ) ;
65+ } ) ;
0 commit comments