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.
Files changed (47) hide show
  1. package/.github/workflows/publish.yml +25 -0
  2. package/build/flagsmith-engine/identities/models.d.ts +1 -1
  3. package/build/flagsmith-engine/identities/models.js +2 -1
  4. package/build/flagsmith-engine/segments/evaluators.js +3 -2
  5. package/examples/README.md +3 -0
  6. package/flagsmith-engine/identities/models.ts +3 -1
  7. package/flagsmith-engine/segments/evaluators.ts +4 -3
  8. package/package.json +1 -1
  9. package/tests/engine/unit/segments/segment_evaluators.test.ts +46 -6
  10. package/.vscode/launch.json +0 -18
  11. package/examples/api-proxy/.babelrc +0 -3
  12. package/examples/api-proxy/.eslintrc +0 -8
  13. package/examples/api-proxy/README.md +0 -12
  14. package/examples/api-proxy/package-lock.json +0 -10889
  15. package/examples/api-proxy/package.json +0 -57
  16. package/examples/api-proxy/src/api/index.js +0 -42
  17. package/examples/api-proxy/src/index.js +0 -29
  18. package/examples/basic/.babelrc +0 -3
  19. package/examples/basic/.eslintrc +0 -8
  20. package/examples/basic/README.md +0 -10
  21. package/examples/basic/package-lock.json +0 -10779
  22. package/examples/basic/package.json +0 -56
  23. package/examples/basic/src/api/index.js +0 -33
  24. package/examples/basic/src/index.js +0 -29
  25. package/examples/caching/.babelrc +0 -3
  26. package/examples/caching/.eslintrc +0 -8
  27. package/examples/caching/README.md +0 -9
  28. package/examples/caching/package-lock.json +0 -6750
  29. package/examples/caching/package.json +0 -56
  30. package/examples/caching/src/api/index.js +0 -38
  31. package/examples/caching/src/index.js +0 -29
  32. package/examples/custom-fetch-agent/.babelrc +0 -3
  33. package/examples/custom-fetch-agent/.eslintrc +0 -8
  34. package/examples/custom-fetch-agent/README.md +0 -12
  35. package/examples/custom-fetch-agent/package-lock.json +0 -6750
  36. package/examples/custom-fetch-agent/package.json +0 -56
  37. package/examples/custom-fetch-agent/src/api/index.js +0 -34
  38. package/examples/custom-fetch-agent/src/index.js +0 -29
  39. package/examples/local-evaluation/.babelrc +0 -3
  40. package/examples/local-evaluation/.eslintrc +0 -8
  41. package/examples/local-evaluation/README.md +0 -18
  42. package/examples/local-evaluation/package-lock.json +0 -6668
  43. package/examples/local-evaluation/package.json +0 -56
  44. package/examples/local-evaluation/src/api/index.js +0 -39
  45. package/examples/local-evaluation/src/index.js +0 -29
  46. package/tests/engine/engine-tests/engine-test-data/data/environment_n9fbf9h3v4fFgH3U3ngWhb.json +0 -12591
  47. 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,34 +0,0 @@
1
- import {Router} from 'express'
2
- import Flagsmith from '../../../../build'
3
-
4
- const environmentKey = 'NowEDzKzNJXZVTVanLVdMQ';
5
- import https from 'https'
6
- const flagsmith = new Flagsmith({
7
- environmentKey,
8
- agent: new https.Agent({keepAlive:true})
9
- });
10
-
11
- const api = () => {
12
- const api = Router();
13
-
14
- api.get('/', async (req, res) => {
15
- const flags = await flagsmith.getEnvironmentFlags();
16
- res.json(flags);
17
- });
18
-
19
- api.get('/:user', async (req, res) => {
20
- const flags = await flagsmith.getIdentityFlags(req.params.user, { checkout_v2: 1 });
21
- const fontSize = flags.getFeatureValue('font_size');
22
- const checkoutV2 = flags.isFeatureEnabled('checkout_v2');
23
- res.json({ fontSize, checkoutV2 });
24
- });
25
-
26
- api.get('/:user/segments', async (req, res) => {
27
- const segments = await flagsmith.getIdentitySegments(req.params.user, { checkout_v2: 1 });
28
- res.json(segments.map(v => v.name));
29
- });
30
-
31
- return api;
32
- };
33
-
34
- 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,3 +0,0 @@
1
- {
2
- "presets": ["@babel/preset-env"]
3
- }
@@ -1,8 +0,0 @@
1
- {
2
- "extends": ["eslint:recommended", "prettier"],
3
- "parserOptions": {
4
- "ecmaVersion": 2018,
5
- "sourceType": "module"
6
- },
7
- "env": { "es6": true, "node": true }
8
- }
@@ -1,18 +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 Local evaluation
4
-
5
- In this mode, all flag values are calculated locally, on your server. The Flagsmith SDK includes an implementation of the Flag Engine, and the engine runs within your server environment within the Flagsmith SDK.
6
-
7
-
8
- **Note that this example requires a **Server-side Environment Key**, you can generate this from your Environment Settings.
9
-
10
- Read More about the differences between local and remote evaluation [here](https://docs.flagsmith.com/clients/overview#remote-and-local-evaluation-modes).
11
-
12
-
13
- ## Running the example
14
-
15
- ```shell
16
- npm i
17
- npm run dev
18
- ```