-
Notifications
You must be signed in to change notification settings - Fork 73
/
Copy pathwith_instance.ts
38 lines (30 loc) · 1020 Bytes
/
with_instance.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import * as express from 'express'; // eslint-disable-line import/no-unresolved
import { Unleash, Strategy } from '../lib/unleash';
const fixture = require('./fixtures/format-0.json');
const app = express();
app.get('/', (req, res) => res.json(fixture));
app.listen(1234);
const strategies: Strategy[] = [
new Strategy('default', true),
new Strategy('ActiveForUserWithEmail', true),
new Strategy('default'),
];
const client = new Unleash({
appName: 'super-app',
backupPath: __dirname,
url: 'http://localhost:1234',
strategies,
});
client.on('error', console.error);
client.on('warn', console.log);
client.on('ready', () => {
setTimeout(() => {
console.log('featureX', client.isEnabled('featureX', {}));
console.log('featureY', client.isEnabled('featureY', {}));
}, 100);
});
console.log('featureX', client.isEnabled('featureX', {}));
setInterval(() => {
console.log('featureX', client.isEnabled('featureX', {}));
console.log('featureY', client.isEnabled('featureY', {}));
}, 5000);