forked from ypereirareis/docker-satis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
server.js
31 lines (25 loc) · 914 Bytes
/
server.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
var http = require('http');
var sys = require('sys');
var exec = require('child_process').exec;
var express = require('express');
var app = express();
// Add headers
app.use(function (req, res, next) {
res.setHeader('Access-Control-Allow-Origin', '*');
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
res.setHeader('Access-Control-Allow-Headers', 'X-Requested-With,content-type');
res.setHeader('Access-Control-Allow-Credentials', true);
next();
});
var buildHook = function (req, res) {
exec("/app/scripts/build.sh", function (error, stdout, stderr) {
if (stdout) res.end(stdout);
});
};
app.get('/build', buildHook);
app.post('/build', buildHook);
var server = app.listen(3000, function () {
var host = server.address().address
var port = server.address().port
console.log('Satis server listening at http://%s:%s', host, port)
});