A simple receiver that receives webhooks sent from discourse

Hierarchy

  • EventEmitter
    • WebhookReceptor

Constructors

Properties

_app: Express = ...
prefixed: string | boolean

Accessors

Methods

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns WebhookReceptor

  • Calls each of the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Rest ...args: any[]

    Returns boolean

  • Return an array listing the events for which the emitter has registered listeners.

    Returns (string | symbol)[]

  • Return the number of listeners listening to a given event.

    Parameters

    • event: string | symbol

    Returns number

  • Return the listeners registered for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T

    Returns ((...args) => void)[]

  • Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns WebhookReceptor

  • It is triggered when discourse sends an webhook event.

    Example

    api.webhook.on("post", (post, res) => {
    console.log(post.raw);
    res.json({"text": "200 ok"});
    })

    Specially, the "default" event will be triggered when the incoming event is not registered in any on function. And the "all" event will be triggered in every webhook event.

    Type Parameters

    Parameters

    Returns WebhookReceptor

  • Add a one-time listener for a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any

    Returns WebhookReceptor

  • Allow post requests on the specified path

    Parameters

    • path: string

    Returns void

  • Remove all listeners, or those of the specified event.

    Parameters

    • Optional event: string | symbol

    Returns WebhookReceptor

  • Remove the listeners of a given event.

    Type Parameters

    • T extends string | symbol

    Parameters

    • event: T
    • Optional fn: ((...args) => void)
        • (...args): void
        • Parameters

          • Rest ...args: any[]

          Returns void

    • Optional context: any
    • Optional once: boolean

    Returns WebhookReceptor

  • Open webhook receptor

    Parameters

    • port: number = 80

      The port

    Returns Promise<unknown>

Generated using TypeDoc