Options
All
  • Public
  • Public/Protected
  • All
Menu

Miscellaneous utility functions.

Index

Functions

failure

  • failure(callback: ServerlessCallback, reason: string): void
  • Small helper function to cause a Function to emit an error response.

    Usage: return failure(callback, 'An error occurred');

    Parameters

    • callback: ServerlessCallback

      A Serverless callback.

    • reason: string

      An error message.

    Returns void

requireAsset

  • requireAsset(assetPath: string): any
  • Works like NodeJS require, but loads code from the requested Twilio Asset path.

    Usually, non-NPM code libraries included in your Function deployment bundle cannot be accessed by their filename; instead, use either a Twilio Asset path or a private Function name, depending on whether your code is in the assets or the functions directory.

    Usage: const mylib = requireAsset('mylib');

    Parameters

    • assetPath: string

      The path to the Twilio Asset you want to load as code.

    Returns any

    A NodeJS module.

requireFunction

  • requireFunction(functionName: string): any
  • Works like NodeJS require, but loads code from the requested Twilio Function name.

    Usually, non-NPM code libraries included in your Function deployment bundle cannot be accessed by their filename; instead, use either a Twilio Asset path or a private Function name, depending on whether your code is in the assets or the functions directory.

    Usage: const mylib = requireFunction('mylib');

    Parameters

    • functionName: string

      The name of the Twilio Function whose code you want to load.

    Returns any

    A NodeJS module.

success

  • success(callback: ServerlessCallback, data?: {}): void
  • Small helper function to cause a Function to emit a successful response.

    Usage: return success(callback, {message: 'Completed successfully'});

    Parameters

    • callback: ServerlessCallback

      A Serverless callback.

    • data: {} = {}

      An optional JSON object to be included with the response.

      Returns void

    Generated using TypeDoc