Variable utilsConst

utils: { argv: { [key: string]: string }; arrayStartingMatch: ((a: any[], b: any[]) => boolean); arrayUnique: ((arr: any[]) => any[]); collapseObjectToArray: ((obj: Record<string, any>) => any[] | boolean); ensureNoTsHeaderFiles: ((files: string[]) => string[]); eventLoopDelay: ((iterations?: number) => Promise<number>); fileUtils: { createDirSafely: ((dir: string) => string); createFileSafely: ((file: string, data: string | ArrayBufferView, overwrite?: boolean) => string); createLinkfileSafely: ((filePath: string, type: string) => string); createSymlinkSafely: ((destination: string, source: string) => string); dirExists: ((dir: string) => boolean); fileExists: ((file: string) => boolean); removeLinkfileSafely: ((filePath: string) => string) }; filterObjectForLogging: ((params: Record<string, any>) => Record<string, any>); filterResponseForLogging: ((response: Record<string, any>) => { [key: string]: any }); getExternalIPAddress: (() => string); hashMerge: ((a: Record<string, any>, b: Record<string, any>, arg?: Record<string, any>) => { [key: string]: any }); isPlainObject: ((o: any) => boolean); isRunning: ((pid: number) => boolean); parseCookies: ((req: { headers: { [key: string]: string | string[] } }) => object); parseHeadersForClientAddress: ((headers: Record<string, string | string[]>) => { ip: string; port: string | number }); parseIPv6URI: ((addr: string) => { host: string; port: number }); replaceDistWithSrc: ((f: string) => string); sleep: ((time: number) => Promise<void>); sortGlobalMiddleware: ((globalMiddlewareList: any[], middleware: { [key: string]: any }) => void); sourceRelativeLinkPath: ((linkFile: string, pluginPaths: string[]) => string | boolean) } = ...

Utility functions for Actionhero

Type declaration

  • argv: { [key: string]: string }
    • [key: string]: string
  • arrayStartingMatch: ((a: any[], b: any[]) => boolean)
      • (a: any[], b: any[]): boolean
      • Compare the first n elements of an array with another, longer array

        Parameters

        • a: any[]
        • b: any[]

        Returns boolean

  • arrayUnique: ((arr: any[]) => any[])
      • (arr: any[]): any[]
      • Return only the unique values in an Array.

        Parameters

        • arr: any[]

        Returns any[]

  • collapseObjectToArray: ((obj: Record<string, any>) => any[] | boolean)
      • (obj: Record<string, any>): any[] | boolean
      • Collapses an Object with numerical keys (like arguments in a function) to an Array

        Parameters

        • obj: Record<string, any>

        Returns any[] | boolean

  • ensureNoTsHeaderFiles: ((files: string[]) => string[])
      • (files: string[]): string[]
      • swap out d.ts files for the JS versions when running with ts-node

        Parameters

        • files: string[]

        Returns string[]

  • eventLoopDelay: ((iterations?: number) => Promise<number>)
      • (iterations?: number): Promise<number>
      • Returns the average delay between a tick of the node.js event loop, as measured for N calls of process.nextTick

        Parameters

        • iterations: number = 10000

        Returns Promise<number>

  • fileUtils: { createDirSafely: ((dir: string) => string); createFileSafely: ((file: string, data: string | ArrayBufferView, overwrite?: boolean) => string); createLinkfileSafely: ((filePath: string, type: string) => string); createSymlinkSafely: ((destination: string, source: string) => string); dirExists: ((dir: string) => boolean); fileExists: ((file: string) => boolean); removeLinkfileSafely: ((filePath: string) => string) }
    • createDirSafely: ((dir: string) => string)
        • (dir: string): string
        • Create a directory, only if it doesn't exist yet. Throws an error if the directory already exists, or encounters a filesystem problem.

          Parameters

          • dir: string

          Returns string

    • createFileSafely: ((file: string, data: string | ArrayBufferView, overwrite?: boolean) => string)
        • (file: string, data: string | ArrayBufferView, overwrite?: boolean): string
        • Create a file, only if it doesn't exist yet. Throws an error if the file already exists, or encounters a filesystem problem.

          Parameters

          • file: string
          • data: string | ArrayBufferView
          • overwrite: boolean = false

          Returns string

    • createLinkfileSafely: ((filePath: string, type: string) => string)
        • (filePath: string, type: string): string
        • Create an Actionhero LinkFile, only if it doesn't exist yet. Throws an error if the file already exists, or encounters a filesystem problem.

          Parameters

          • filePath: string
          • type: string

          Returns string

    • createSymlinkSafely: ((destination: string, source: string) => string)
        • (destination: string, source: string): string
        • Create a system symbolic link. Throws an error if it encounters a filesystem problem.

          Parameters

          • destination: string
          • source: string

          Returns string

    • dirExists: ((dir: string) => boolean)
        • (dir: string): boolean
        • Check if a directory exists.

          Parameters

          • dir: string

          Returns boolean

    • fileExists: ((file: string) => boolean)
        • (file: string): boolean
        • Check if a file exists.

          Parameters

          • file: string

          Returns boolean

    • removeLinkfileSafely: ((filePath: string) => string)
        • (filePath: string): string
        • Remove an Actionhero LinkFile, only if it exists. Throws an error if the file does not exist, or encounters a filesystem problem.

          Parameters

          • filePath: string

          Returns string

  • filterObjectForLogging: ((params: Record<string, any>) => Record<string, any>)
      • (params: Record<string, any>): Record<string, any>
      • Prepares acton params for logging. Hides any sensitive data as defined by api.config.general.filteredParams Truncates long strings via api.config.logger.maxLogStringLength

        Parameters

        • params: Record<string, any>

        Returns Record<string, any>

  • filterResponseForLogging: ((response: Record<string, any>) => { [key: string]: any })
      • (response: Record<string, any>): { [key: string]: any }
      • Prepares acton response for logging. Hides any sensitive data as defined by api.config.general.filteredResponse Truncates long strings via api.config.logger.maxLogStringLength

        Parameters

        • response: Record<string, any>

        Returns { [key: string]: any }

        • [key: string]: any
  • getExternalIPAddress: (() => string)
      • (): string
      • Returns this server's external/public IP address

        Returns string

  • hashMerge: ((a: Record<string, any>, b: Record<string, any>, arg?: Record<string, any>) => { [key: string]: any })
      • (a: Record<string, any>, b: Record<string, any>, arg?: Record<string, any>): { [key: string]: any }
      • Recursively merge 2 Objects together. Will resolve functions if they are present, unless the parent Object has the property _toExpand = false. Actionhero uses this internally to construct and resolve the config. Matching keys in B override A.

        Parameters

        • a: Record<string, any>
        • b: Record<string, any>
        • Optional arg: Record<string, any>

        Returns { [key: string]: any }

        • [key: string]: any
  • isPlainObject: ((o: any) => boolean)
      • (o: any): boolean
      • Is the JS Object passed in truly just an object?

        Parameters

        • o: any

        Returns boolean

  • isRunning: ((pid: number) => boolean)
      • (pid: number): boolean
      • Parameters

        • pid: number

        Returns boolean

  • parseCookies: ((req: { headers: { [key: string]: string | string[] } }) => object)
      • (req: { headers: { [key: string]: string | string[] } }): object
      • Transform the cookie headers of a node HTTP req Object into a hash.

        Parameters

        • req: { headers: { [key: string]: string | string[] } }
          • headers: { [key: string]: string | string[] }
            • [key: string]: string | string[]

        Returns object

  • parseHeadersForClientAddress: ((headers: Record<string, string | string[]>) => { ip: string; port: string | number })
      • (headers: Record<string, string | string[]>): { ip: string; port: string | number }
      • Return ip and port information if defined in the header

        Parameters

        • headers: Record<string, string | string[]>

        Returns { ip: string; port: string | number }

        • ip: string
        • port: string | number
  • parseIPv6URI: ((addr: string) => { host: string; port: number })
  • replaceDistWithSrc: ((f: string) => string)
      • (f: string): string
      • Used by generator functions running from your dist, it replaces the path with your src Relies on api.config.general.paths

        Parameters

        • f: string

        Returns string

  • sleep: ((time: number) => Promise<void>)
      • (time: number): Promise<void>
      • Sleep with a Promise

        Parameters

        • time: number

        Returns Promise<void>

  • sortGlobalMiddleware: ((globalMiddlewareList: any[], middleware: { [key: string]: any }) => void)
      • (globalMiddlewareList: any[], middleware: { [key: string]: any }): void
      • Sorts an Array of Objects with a priority key

        Parameters

        • globalMiddlewareList: any[]
        • middleware: { [key: string]: any }
          • [key: string]: any

        Returns void

  • sourceRelativeLinkPath: ((linkFile: string, pluginPaths: string[]) => string | boolean)
      • (linkFile: string, pluginPaths: string[]): string | boolean
      • Parameters

        • linkFile: string
        • pluginPaths: string[]

        Returns string | boolean

Generated using TypeDoc