Skip to content

Commit 81a48ba

Browse files
update
1 parent d632aef commit 81a48ba

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

examples/express-app/server.mjs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1+
// Copyright (c) Microsoft Corporation.
2+
// Licensed under the MIT license.
3+
14
import express from "express";
2-
import path from "path";
35

46
import { load } from "@azure/app-configuration-provider";
5-
const connectionString = "<your-connection-string>";;
7+
const connectionString = "<your-connection-string>";
68
const appConfig = await load(connectionString, {
79
featureFlagOptions: {
810
enabled: true,
@@ -25,6 +27,7 @@ import { ConfigurationObjectFeatureFlagProvider, ConfigurationMapFeatureFlagProv
2527
You can use either ConfigurationObjectFeatureFlagProvider or ConfigurationMapFeatureFlagProvider to provide feature flags.
2628
We 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
3841
server.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

4548
server.get("/", (req, res) => {
46-
appConfig.refresh();
4749
res.send("Hello World!");
4850
});
4951

5052
server.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
6263
server.listen(PORT, () => {
6364
console.log(`Server is running at http://localhost:${PORT}`);
64-
});
65+
});

0 commit comments

Comments
 (0)