Options
All
  • Public
  • Public/Protected
  • All
Menu

The app parameter available to ApplicationFunctions

property

{logger} log - A logger

Hierarchy

  • Application

Index

Constructors

Properties

Methods

Constructors

constructor

Properties

app

app: function

Type declaration

    • (): string
    • Returns string

cache

cache: Cache

events

events: EventEmitter

log

router

router: express.Router

Methods

Private auth

  • Authenticate and get a GitHub client that can be used to make API calls.

    You'll probably want to use context.github instead.

    Note: app.auth is asynchronous, so it needs to be prefixed with a await to wait for the magic to happen.

     module.exports = (app) => {
       app.on('issues.opened', async context => {
         const github = await app.auth();
       });
     };

    Parameters

    • Optional id: undefined | number

      ID of the installation, which can be extracted from context.payload.installation.id. If called without this parameter, the client wil authenticate as the app instead of as a specific installation, which means it can only be used for app APIs.

    • Default value log: LoggerWithTarget = this.log

    Returns Promise<GitHubAPI>

    An authenticated GitHub API client

load

on

  • on(eventName: string | string[], callback: function): void
  • Listen for GitHub webhooks, which are fired for almost every significant action that users take on GitHub.

    Parameters

    • eventName: string | string[]
    • callback: function

      a function to call when the webhook is received.

        • (context: Context): Promise<void>
        • Parameters

          Returns Promise<void>

    Returns void

receive

  • receive(event: WebhookEvent): Promise<Object>
  • Parameters

    • event: WebhookEvent

    Returns Promise<Object>

route

  • route(path?: undefined | string): express.Router
  • Get an express router that can be used to expose HTTP endpoints

    module.exports = app => {
      // Get an express router to expose new HTTP endpoints
      const route = app.route('/my-app');
    
      // Use any middleware
      route.use(require('express').static(__dirname + '/public'));
    
      // Add a new route
      route.get('/hello-world', (req, res) => {
        res.end('Hello World');
      });
    };

    Parameters

    • Optional path: undefined | string

      the prefix for the routes

    Returns express.Router

    an express.Router

Legend

  • Module
  • Object literal
  • Variable
  • Function
  • Function with type parameter
  • Index signature
  • Type alias
  • Enumeration
  • Enumeration member
  • Property
  • Method
  • Interface
  • Interface with type parameter
  • Constructor
  • Property
  • Method
  • Index signature
  • Class
  • Class with type parameter
  • Constructor
  • Property
  • Method
  • Accessor
  • Index signature
  • Inherited constructor
  • Inherited property
  • Inherited method
  • Inherited accessor
  • Protected property
  • Protected method
  • Protected accessor
  • Private property
  • Private method
  • Private accessor
  • Static property
  • Static method

Generated using TypeDoc