-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnotify.js
More file actions
54 lines (43 loc) · 1.91 KB
/
Copy pathnotify.js
File metadata and controls
54 lines (43 loc) · 1.91 KB
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
47
48
49
50
51
52
53
require('org.pinf.genesis.lib/lib/api').forModule(require, module, function (API, exports) {
// Expose a HTTP interface.
exports["github.com/creationix/stack/0"] = function (req, res, next) {
console.log("req.url", req.url);
console.log("req.args", req.args);
console.log("req.params", req.params);
console.log("req.body", req.body);
return res.end("Hello World!!!");
}
});
/*
app.post("/notify", function (req, res, next) {
var r = res.r;
var info = null;
try {
var payload = JSON.parse(req.body.payload);
if (payload.ref) {
var branchMatch = payload.ref.match(/^refs\/heads\/(.+)$/);
if (branchMatch) {
info = {
id: "github.com/" + payload.repository.organization + "/" + payload.repository.name + "/build/" + payload.after,
repository: "github.com/" + payload.repository.organization + "/" + payload.repository.name,
commit: payload.after,
branch: branchMatch[1],
createdOn: (new Date(payload.head_commit.timestamp)).getTime(),
createdBy: "github.com/" + payload.pusher.name,
status: "pending"
};
} else {
console.log("payload", JSON.stringify(payload, null, 4));
console.log("Warning: Ignoring event as branch '" + payload.ref + "' could not be matched!");
}
} else {
console.log("payload", JSON.stringify(payload, null, 4));
console.log("Warning: Ignoring event as branch '" + payload.ref + "' not set!");
}
} catch(err) {
console.log("req.body.payload", req.body.payload);
console.error("Error '" + err.message + "' parsing payload");
return next(err);
}
}
*/