-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhandler.js
44 lines (35 loc) · 1.25 KB
/
handler.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
'use strict';
var BitbucketHandler = require('./lib/BitbucketHandler');
var exports = function() {
this.configure = this.configure.bind(this);
this.options = this.options.bind(this);
this.run = this.run.bind(this);
this.yargs = null;
};
var server = {};
exports.shortDescription = 'Runs a webhook handler and sends updates to bitbucket status API.';
exports.help = 'Usage: npm start [args]';
exports.help += '\n';
exports.help += 'Provides a bitbucket webhook endpoint.';
exports.options = function(yargs) {
this.yargs = yargs;
return yargs
.describe('help', 'Displays this message.')
.alias('help', 'h')
.describe('port', 'The port on which to listen for incoming requests.')
.alias('port', 'p')
.describe('bitbucket-webhook-path', 'The path at which to listen for webhooks.')
.alias('bitbucket-webhook-path', 'P')
.describe('bitbucket-webhook-secret', 'The webhook secret provided to Bitbucket.')
.alias('bitbucket-webhook-secret', 's')
.describe('bitbucket-api-token', 'The API token to use to write to Bitbucket.')
.alias('bitbucket-api-token', 'a')
;
};
exports.configure = function(config) {
server = new BitbucketHandler(config);
};
exports.run = function(cb) {
server.start();
};
module.exports = exports;