-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathsample.rest.js
46 lines (41 loc) · 1.21 KB
/
sample.rest.js
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
39
40
41
42
43
44
45
46
/*
* Sample configuration file for Fliplet Agent
* Usage: fliplet-agent start ./sample.js
*/
module.exports.config = {
// Fliplet authorisation token from Fliplet Studio
authToken: 'eu--123456789',
// Set to true to test the integration without sending any data to Fliplet servers
isDryRun: false,
// If set to true, operations will run when the script starts.
// Otherwise, they will just run according to their frequency.
syncOnInit: true
};
module.exports.setup = (agent) => {
// Push data from your API to a Fliplet Data Source
agent.push({
description: 'Pushes data from my table to Fliplet',
frequency: '* * * * *',
source: (rest) => rest.get('https://jsonplaceholder.typicode.com/todos'),
primaryColumnName: 'id',
caseInsensitivePrimaryColumn: true,
timestampColumnName: 'updatedAt',
targetDataSourceId: 123,
encrypt: {
fields: ['title']
},
merge: true
});
// Pull data from a Fliplet Data Source
agent.pull({
description: 'Pull data from a Fliplet data source to my database',
frequency: '* * * * *',
targetDataSourceId: 456,
where: {
'Foo': 'Bar'
},
action: (entries, db) => {
console.log(entries)
},
});
};