Options
All
  • Public
  • Public/Protected
  • All
Menu

Index

Functions

createRouterForBot

  • Create a new router for a module. Once created, use them to register new endpoints. Routers created with this method are accessible via the url /mod/{routernName}

    example

    const router = bp.http.createRouterForBot('myModule')

    example

    router.get('/list', ...)

    example

    axios.get('/mod/myModule/list')

    Parameters

    • routerName: string

      The name of the router

    • Optional options: RouterOptions

      Additional options to apply to the router

    Returns any & RouterExtension

createShortLink

  • createShortLink(name: string, destination: string, params?: any): void
  • Create a shortlink to any destination

    example

    bp.http.createShortLink('chat', '/lite', {m: 'channel-web', v: 'fullscreen' })

    example

    http://localhost:3000/s/chat

    Parameters

    • name: string

      The name of the link, must be unique

    • destination: string

      The URL to redirect to. It can be relative or absolute

    • Optional params: any

      An optional query string to add at the end of the url. You may specify an object

    Returns void

decodeExternalToken

  • decodeExternalToken(token: string): Promise<any>
  • Decodes and validates an external authorization token with the public key defined in config file

    Parameters

    • token: string

      The encoded JWT token

    Returns Promise<any>

    The decoded payload

deleteRouterForBot

  • deleteRouterForBot(routerName: string): any
  • This method is meant to unregister a router before unloading a module. It is meant to be used in a development environment. It could cause unpredictable behaviour in production

    Parameters

    • routerName: string

      The name of the router (must have been registered with createRouterForBot)

    Returns any

deleteShortLink

  • deleteShortLink(name: any): void
  • Delete any previously created short link

    Parameters

    • name: any

      The name of the link to remove

    Returns void

extractExternalToken

  • extractExternalToken(req: any, res: any, next: any): Promise<void>
  • This Express middleware tries to decode the X-BP-ExternalAuth header and adds a credentials header in the request if it's valid.

    Parameters

    • req: any
    • res: any
    • next: any

    Returns Promise<void>

getAxiosConfigForBot

  • Returns the required configuration to make an API call to another module by specifying only the relative path.

    Parameters

    • botId: string

      The ID of the bot for which to get the configuration

    • Optional options: AxiosOptions

    Returns Promise<AxiosBotConfig>

    The configuration to use

Generated using TypeDoc