Options
All
  • Public
  • Public/Protected
  • All
Menu

Module utils

Index

References

SearchConfig

Re-exports SearchConfig

ValidPathResult

Re-exports ValidPathResult

access

Re-exports access

checkForValidPath

Re-exports checkForValidPath

fileExists

Re-exports fileExists

getContentType

Re-exports getContentType

getDirContent

Re-exports getDirContent

getFirstMatchingDirectory

Re-exports getFirstMatchingDirectory

getListOfFunctionsAndAssets

Re-exports getListOfFunctionsAndAssets

getPathAndAccessFromFileInfo

Re-exports getPathAndAccessFromFileInfo

readDir

Re-exports readDir

readFile

Re-exports readFile

sleep

Re-exports sleep

stat

Re-exports stat

writeFile

Re-exports writeFile

Type aliases

SearchConfig

SearchConfig: { assetsFolderNames?: string[]; functionsFolderNames?: string[] }

Type declaration

  • Optional assetsFolderNames?: string[]

    Ordered folder names to search for to find assets

  • Optional functionsFolderNames?: string[]

    Ordered folder names to search for to find functions

TwilioApiError

TwilioApiError: { code: number; message: string; more_info: string; status: number }

Type declaration

  • code: number
  • message: string
  • more_info: string
  • status: number

ValidPathResult

ValidPathResult: { valid: true } | { message: string; valid: false }

Variables

Const access

access: __promisify__ = promisify(fs.access)

Const allPropertiesRedactor

allPropertiesRedactor: <T>(val: T) => string = fastRedact({paths: ['*'],})

Type declaration

    • <T>(val: T): string
    • Type parameters

      • T

      Parameters

      • val: T

      Returns string

Const generalRedactor

generalRedactor: <T>(val: T) => string = fastRedact({paths: ['env.*','pkgJson.*',...prefixAllEntriesWithWildcard(['authToken','apiSecret','username','password','cookies','AUTH_TOKEN','API_SECRET','TWILIO_AUTH_TOKEN','TWILIO_API_SECRET',]),],})

Type declaration

    • <T>(val: T): string
    • Type parameters

      • T

      Parameters

      • val: T

      Returns string

Const readDir

readDir: (arg1: T1) => Promise<TResult> = promisify(recursiveReadDir)

Type declaration

    • (arg1: T1): Promise<TResult>
    • Parameters

      • arg1: T1

      Returns Promise<TResult>

Const readFile

readFile: __promisify__ = promisify(fs.readFile)

Const stat

stat: __promisify__ = promisify(fs.stat)

Const writeFile

writeFile: __promisify__ = promisify(fs.writeFile)

Functions

checkForValidPath

  • Verifies a given path against the restrictions put up by the Twilio Runtime.

    Parameters

    • path: string

      a potential absolute path for a Function or Asset

    Returns ValidPathResult

convertApiErrorsAndThrow

  • convertApiErrorsAndThrow(err: any): never
  • Throws the error it receives and if it's an HTTP Error it will convert it to a ClientApiError

    Parameters

    • err: any

    Returns never

fileExists

  • fileExists(filePath: string): Promise<boolean>
  • Checks if a given file exists by checking if we have read & write access

    export

    Parameters

    • filePath: string

      full path of the file to check

    Returns Promise<boolean>

filterUrl

  • filterUrl(unfilteredUrl: string | undefined): string
  • Explictly removes username and password from a URL.

    Parameters

    • unfilteredUrl: string | undefined

      any URL string

    Returns string

getContentType

  • getContentType(content: string | Buffer, name?: undefined | string): Promise<string | undefined>
  • Tries to determine the content type of a string or buffer

    export

    Parameters

    • content: string | Buffer

      the content to check

    • Optional name: undefined | string

    Returns Promise<string | undefined>

    a valid content type or undefined

getDirContent

  • getDirContent(dir: string, extension?: undefined | string): Promise<FileInfo[]>
  • Retrieves all (nested) files from a given directory.

    If an extension is specified it will be used to filter the results.

    export

    Parameters

    • dir: string

      the directory to be checked

    • Optional extension: undefined | string

    Returns Promise<FileInfo[]>

getFirstMatchingDirectory

  • getFirstMatchingDirectory(basePath: string, directories: string[]): string
  • Given a list of directory names it will return the first one that exists in the base path.

    Important: Performs synchronous file system reading

    export

    Parameters

    • basePath: string
    • directories: string[]

    Returns string

getListOfFunctionsAndAssets

  • Retrieves a list of functions and assets existing in a given base directory Will check for both "functions" and "src" as directory for functions and "assets" and "static" for assets

    export

    Parameters

    • cwd: string

      Directory

    • Default value config: SearchConfig = {}

      lets you override the folders to use

    Returns Promise<DirectoryContent>

getPathAndAccessFromFileInfo

  • Determines the access and Serverless path for a filesystem resource. If it receives an ignore extension it will drop it from the final serverless path

    export

    Parameters

    • file: FileInfo

      the file to get the access and path for

    • Optional ignoreExtension: undefined | string

    Returns ResourcePathAndAccess

getUserAgent

  • getUserAgent(extensions?: string[]): string
  • Parameters

    • Default value extensions: string[] = []

    Returns string

Generated using TypeDoc