Skip to content

Commit ba8e1a4

Browse files
update
1 parent 9a80691 commit ba8e1a4

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

examples/express-app/README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ The examples are compatible with [LTS versions of Node.js](https://github.com/no
88

99
## Setup & Run
1010

11-
1. Build:
11+
1. Go to `src/feature-management` under the root folder and run:
1212

1313
```bash
14+
npm run install
1415
npm run build
1516
```
1617

17-
1. Install the dependencies using `npm`:
18+
1. Go back to `examples/express-app` and install the dependencies using `npm`:
1819

1920
```bash
2021
npm install
@@ -40,7 +41,9 @@ The targeting mechanism uses the `exampleTargetingContextAccessor` to extract th
4041
const exampleTargetingContextAccessor = {
4142
getTargetingContext: () => {
4243
const req = requestAccessor.getStore();
44+
// read user and groups from request query data
4345
const { userId, groups } = req.query;
46+
// return aa ITargetingContext with the appropriate user info
4447
return { userId: userId, groups: groups ? groups.split(",") : [] };
4548
}
4649
};

examples/express-app/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
{
22
"scripts": {
3-
"start": "node server.mjs",
4-
"build": "cd ../../src/feature-management && npm i && npm run build && cd ../../examples/express-app && npm i"
3+
"start": "node server.mjs"
54
},
65
"dependencies": {
76
"@microsoft/feature-management": "../../src/feature-management",

examples/express-app/server.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ const requestAccessor = new AsyncLocalStorage();
1515
const exampleTargetingContextAccessor = {
1616
getTargetingContext: () => {
1717
const req = requestAccessor.getStore();
18+
// read user and groups from request query data
1819
const { userId, groups } = req.query;
20+
// return an ITargetingContext with the appropriate user info
1921
return { userId: userId, groups: groups ? groups.split(",") : [] };
2022
}
2123
};

0 commit comments

Comments
 (0)