-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhector.js
executable file
·39 lines (31 loc) · 1010 Bytes
/
hector.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
#!/usr/bin/env node
const express = require('express');
const bodyParser = require('body-parser');
const Broker = require(`./core_observers/observers`).Broker;
const Observer = require(`./core_observers/observers`).Observer;
/*
Express application
*/
let app = express();
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(express.static('clones'));
let broker = new Broker();
require(`./core_observers/messengerObserver`).initialize(broker);
// load plugin
require(`${process.env.HECTOR_PLUGIN_PATH}/main.js`).run(broker);
/*
this route is called from the DVCS (eg GitHub)
(see webhooks in your DVCS settings)
*/
app.post('/ci', (req, res) => {
broker.emit('ci_event', req)
/*
# messages
eventsObserver listening on `ci_event`
*/
res.status(201).end();
});
app.listen(process.env.CI_HTTP_PORT)
let message = `🚀 Hector CI Server is started - listening on ${process.env.CI_HTTP_PORT}`;
broker.emit('message', {message: message, from: "Hector"});