flagsmith-nodejs 2.5.2 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/publish.yml +25 -0
- package/build/flagsmith-engine/identities/models.d.ts +1 -1
- package/build/flagsmith-engine/identities/models.js +2 -1
- package/build/flagsmith-engine/segments/evaluators.js +3 -2
- package/examples/README.md +3 -0
- package/flagsmith-engine/identities/models.ts +3 -1
- package/flagsmith-engine/segments/evaluators.ts +4 -3
- package/package.json +1 -1
- package/tests/engine/unit/segments/segment_evaluators.test.ts +46 -6
- package/.vscode/launch.json +0 -18
- package/examples/api-proxy/.babelrc +0 -3
- package/examples/api-proxy/.eslintrc +0 -8
- package/examples/api-proxy/README.md +0 -12
- package/examples/api-proxy/package-lock.json +0 -10889
- package/examples/api-proxy/package.json +0 -57
- package/examples/api-proxy/src/api/index.js +0 -42
- package/examples/api-proxy/src/index.js +0 -29
- package/examples/basic/.babelrc +0 -3
- package/examples/basic/.eslintrc +0 -8
- package/examples/basic/README.md +0 -10
- package/examples/basic/package-lock.json +0 -10779
- package/examples/basic/package.json +0 -56
- package/examples/basic/src/api/index.js +0 -33
- package/examples/basic/src/index.js +0 -29
- package/examples/caching/.babelrc +0 -3
- package/examples/caching/.eslintrc +0 -8
- package/examples/caching/README.md +0 -9
- package/examples/caching/package-lock.json +0 -6750
- package/examples/caching/package.json +0 -56
- package/examples/caching/src/api/index.js +0 -38
- package/examples/caching/src/index.js +0 -29
- package/examples/custom-fetch-agent/.babelrc +0 -3
- package/examples/custom-fetch-agent/.eslintrc +0 -8
- package/examples/custom-fetch-agent/README.md +0 -12
- package/examples/custom-fetch-agent/package-lock.json +0 -6750
- package/examples/custom-fetch-agent/package.json +0 -56
- package/examples/custom-fetch-agent/src/api/index.js +0 -34
- package/examples/custom-fetch-agent/src/index.js +0 -29
- package/examples/local-evaluation/.babelrc +0 -3
- package/examples/local-evaluation/.eslintrc +0 -8
- package/examples/local-evaluation/README.md +0 -18
- package/examples/local-evaluation/package-lock.json +0 -6668
- package/examples/local-evaluation/package.json +0 -56
- package/examples/local-evaluation/src/api/index.js +0 -39
- package/examples/local-evaluation/src/index.js +0 -29
- package/tests/engine/engine-tests/engine-test-data/data/environment_n9fbf9h3v4fFgH3U3ngWhb.json +0 -12591
- package/tests/engine/engine-tests/engine-test-data/readme.md +0 -30
|
@@ -1,56 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "nodejs-es6-boilerplate",
|
|
3
|
-
"version": "1.0.1",
|
|
4
|
-
"description": "Node.js boilerplate with ES6, ESLint, and Prettier",
|
|
5
|
-
"main": "src/index.js",
|
|
6
|
-
"browserslist": [
|
|
7
|
-
"last 2 Chrome versions"
|
|
8
|
-
],
|
|
9
|
-
"scripts": {
|
|
10
|
-
"test": "echo \"Error: no test specified\" && exit 1",
|
|
11
|
-
"clean": "rm -rf build && mkdir build",
|
|
12
|
-
"build-babel": "babel -d ./build ./src -s",
|
|
13
|
-
"build": "npm run clean && npm run build-babel",
|
|
14
|
-
"dev": "nodemon --exec npm start --ignore ./build",
|
|
15
|
-
"node-cache": "^5.1.2",
|
|
16
|
-
"ssg-node-express": "4.16.4",
|
|
17
|
-
"start": "npm run build && node ./build/index.js",
|
|
18
|
-
"format": "prettier --write \"src/**/*.js\"",
|
|
19
|
-
"format:check": "prettier --list-different \"src/**/*.js\"",
|
|
20
|
-
"lint": "eslint \"src/**/*.js\"",
|
|
21
|
-
"lint:fix": "eslint --fix \"src/**/*.js\""
|
|
22
|
-
},
|
|
23
|
-
"repository": "github:vferdiansyah/nodejs-es6-boilerplate",
|
|
24
|
-
"keywords": [
|
|
25
|
-
"javascript",
|
|
26
|
-
"node",
|
|
27
|
-
"nodejs",
|
|
28
|
-
"es6",
|
|
29
|
-
"eslint",
|
|
30
|
-
"prettier",
|
|
31
|
-
"boilerplate"
|
|
32
|
-
],
|
|
33
|
-
"author": {
|
|
34
|
-
"name": "Veri Ferdiansyah",
|
|
35
|
-
"email": "veri.ferdi@gmail.com",
|
|
36
|
-
"url": "https://vferdiansyah.github.io"
|
|
37
|
-
},
|
|
38
|
-
"license": "MIT",
|
|
39
|
-
"bugs": "https://github.com/vferdiansyah/nodejs-es6-boilerplate/issues",
|
|
40
|
-
"homepage": "https://github.com/vferdiansyah/nodejs-es6-boilerplate#readme",
|
|
41
|
-
"devDependencies": {
|
|
42
|
-
"@babel/cli": "^7.18.10",
|
|
43
|
-
"@babel/core": "^7.5.5",
|
|
44
|
-
"@babel/preset-env": "^7.5.5",
|
|
45
|
-
"eslint": "^6.2.1",
|
|
46
|
-
"eslint-config-prettier": "^6.1.0",
|
|
47
|
-
"eslint-plugin-prettier": "^3.1.0",
|
|
48
|
-
"express": "^4.18.1",
|
|
49
|
-
"nodemon": "^2.0.19",
|
|
50
|
-
"prettier": "^1.18.2"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"flagsmith-nodejs": "^2.2.2",
|
|
54
|
-
"node-cache": "^5.1.2"
|
|
55
|
-
}
|
|
56
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import {Router} from 'express'
|
|
2
|
-
import Flagsmith from '../../../../build'
|
|
3
|
-
|
|
4
|
-
const environmentKey = 'NowEDzKzNJXZVTVanLVdMQ';
|
|
5
|
-
import nodecache from "node-cache";
|
|
6
|
-
|
|
7
|
-
const flagsmith = new Flagsmith({
|
|
8
|
-
environmentKey,
|
|
9
|
-
cache: new nodecache({
|
|
10
|
-
stdTTL: 10,
|
|
11
|
-
checkperiod: 10,
|
|
12
|
-
}),
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
const api = () => {
|
|
16
|
-
const api = Router();
|
|
17
|
-
|
|
18
|
-
api.get('/', async (req, res) => {
|
|
19
|
-
const flags = await flagsmith.getEnvironmentFlags();
|
|
20
|
-
res.json(flags);
|
|
21
|
-
});
|
|
22
|
-
|
|
23
|
-
api.get('/:user', async (req, res) => {
|
|
24
|
-
const flags = await flagsmith.getIdentityFlags(req.params.user, { checkout_v2: 1 });
|
|
25
|
-
const fontSize = flags.getFeatureValue('font_size');
|
|
26
|
-
const checkoutV2 = flags.isFeatureEnabled('checkout_v2');
|
|
27
|
-
res.json({ fontSize, checkoutV2 });
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
api.get('/:user/segments', async (req, res) => {
|
|
31
|
-
const segments = await flagsmith.getIdentitySegments(req.params.user, { checkout_v2: 1 });
|
|
32
|
-
res.json(segments.map(v => v.name));
|
|
33
|
-
});
|
|
34
|
-
|
|
35
|
-
return api;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
export default api
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import http from 'http'
|
|
2
|
-
import express from 'express'
|
|
3
|
-
import bodyParser from 'body-parser'
|
|
4
|
-
import api from './api'
|
|
5
|
-
const PORT = process.env.PORT || 3000;
|
|
6
|
-
const app = express();
|
|
7
|
-
|
|
8
|
-
app.server = http.createServer(app);
|
|
9
|
-
|
|
10
|
-
//Apply middleware
|
|
11
|
-
// parse various different custom JSON types as JSON
|
|
12
|
-
app.use(bodyParser.json());
|
|
13
|
-
|
|
14
|
-
// api router
|
|
15
|
-
app.use('/api', api());
|
|
16
|
-
|
|
17
|
-
app.server.listen(PORT);
|
|
18
|
-
console.log('Server started on port ' + PORT);
|
|
19
|
-
console.log();
|
|
20
|
-
console.log('Go to http://localhost:' + PORT + '/api');
|
|
21
|
-
console.log('To get an example response for getFlags');
|
|
22
|
-
console.log();
|
|
23
|
-
console.log('Go to http://localhost:' + PORT + '/api/flagsmith_sample_user');
|
|
24
|
-
console.log('To get an example feature state for a user');
|
|
25
|
-
console.log();
|
|
26
|
-
console.log('Go to http://localhost:' + PORT + '/api/flagsmith_sample_user/segments');
|
|
27
|
-
console.log('To get the segments which the user belongs to');
|
|
28
|
-
|
|
29
|
-
module.exports = app;
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
<img width="100%" src="https://github.com/Flagsmith/flagsmith/raw/main/static-files/hero.png"/>
|
|
2
|
-
|
|
3
|
-
# Flagsmith Node.js example with custom fetch agent
|
|
4
|
-
|
|
5
|
-
This is a simple Flagsmith Node.js example in local evaluation modes with a custom fetch agent. Using a custom fetch agent lets allows you to specify networking related options such as keep alive and socket timeout, read more on this [here](https://github.com/node-fetch/node-fetch#custom-agent).
|
|
6
|
-
|
|
7
|
-
## Running the example
|
|
8
|
-
|
|
9
|
-
```shell
|
|
10
|
-
npm i
|
|
11
|
-
npm run dev
|
|
12
|
-
```
|