forked from evenh/webhook-router
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
31 lines (25 loc) · 830 Bytes
/
index.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
const yaml = require('js-yaml');
const fs = require('fs');
const path = require('path');
const SmeeClient = require('smee-client');
const onDeath = require('death');
const configFile = process.env.WEBHOOK_CONFIG || path.join('etc','webhooks','config.yaml');
const config = yaml.safeLoad(fs.readFileSync(configFile, 'utf8'));
var clients = [];
config.forEach(el => {
console.info("Configuring: " + el.name);
el.sources.forEach(source => {
el.targets.forEach(target => {
const client = new SmeeClient({ source, target });
const events = client.start();
clients.push(events);
})
})
});
onDeath((signal) => {
console.log('Received signal: ' + signal + ". Terminating...");
clients.forEach(client => {
client.close();
});
process.exit();
});