Methods
on(event, callback)
Listen for GitHub webhooks, which are fired for almost every significant action that users take on GitHub.
Parameters:
Name | Type | Description |
---|---|---|
event |
string
|
the name of the
GitHub webhook event. Most events also include an "action". For
example, the *
|
callback |
Robot~webhookCallback
|
a function to call when the webhook is received. |
Example
robot.on('push', context => {
// Code was just pushed.
});
robot.on('issues.opened', context => {
// An issue was just opened.
});
route(path)
Get an express router that can be used to expose HTTP endpoints
Parameters:
Name | Type | Description |
---|---|---|
path |
string
|
the prefix for the routes |
Returns:
Example
module.exports = robot => {
// Get an express router to expose new HTTP endpoints
const app = robot.route('/my-app');
// Use any middleware
app.use(require('express').static(__dirname + '/public'));
// Add a new route
app.get('/hello-world', (req, res) => {
res.end('Hello World');
});
};
Type Definitions
webhookCallback(context)
Do the thing
Parameters:
Name | Type | Description |
---|---|---|
context |
Context
|
the context of the event that was triggered, including
|