This repository has been archived by the owner on Aug 2, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtesting_config.js
53 lines (49 loc) · 1.54 KB
/
testing_config.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
47
48
49
50
51
52
53
// Don't edit this file: it's used for testing.
var util = require('util');
var tasks = require('./tasks.js');
var PORT = 8080;
var RESULTS_FOLDER = 'results';
var hooks = {
// A very basic hook that verifies Hook to Deploy is working.
// GET http://server:port/hook/basicHook?key=basicHookKey
basicHook: {
key: 'basicHookKey',
action: function(req, res) {
res.send({success: 'hello, this is ' + req.params.hookName});
}
},
// Pass arguments to a hook.
// GET http://server:port/hook/deepFryer?key=fryIt&toFry=fresh%20walleye
deepFryer: {
key: 'fryIt',
action: function(req, res) {
if ('toFry' in req.query) {
var item = req.query.toFry;
var text = util.format('I\'m going to fry %s for you now!', item);
res.send({success: text});
} else {
res.send(400, {error: 'You didn\'t give me anything to fry'});
}
}
},
// Spawn a subprocess that may take a while. Return a reference so the user
// can check if the process has finished and view its output.
// GET http://server:port/hook/execPython?key=rngStart
execPython: {
key: 'rngStart',
action: function(req, res) {
var cmd = 'python -c "from random import randrange; from time import sleep; sleep(20); print(randrange(100))"';
tasks.execSaveResults(cmd, RESULTS_FOLDER, function(err, procData) {
if (err)
res.send(500, {error: err});
else
res.send(procData);
});
}
}
};
module.exports = {
port: PORT,
resultsFolder: RESULTS_FOLDER,
hooks: hooks
};