Variable utilsConst

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

Utility functions for Actionhero

Type declaration

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

        Parameters

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

        Returns boolean

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

        Parameters

        • arr: any[]

        Returns any[]

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

        Parameters

        • obj: Record<string, any>

        Returns any[] | boolean

  • deepCopy: (<T>(obj) => T)
      • <T>(obj): T
      • Type Parameters

        • T

        Parameters

        • obj: T

        Returns T

  • ensureNoTsHeaderOrSpecFiles: ((files) => string[])
      • (files): string[]
      • swap out d.ts files for the JS versions when running with ts-node also filter out *.test. and *.spec. js|ts files

        Parameters

        • files: string[]

        Returns string[]

  • eventLoopDelay: ((iterations?) => Promise<number>)
      • (iterations?): 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);
        createFileSafely: ((file, data, overwrite?) => string);
        createLinkfileSafely: ((filePath, type) => string);
        createSymlinkSafely: ((destination, source) => string);
        dirExists: ((dir) => boolean);
        fileExists: ((file) => boolean);
        removeLinkfileSafely: ((filePath) => string);
    }
    • createDirSafely: ((dir) => string)
        • (dir): 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, data, overwrite?) => string)
        • (file, data, overwrite?): 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, type) => string)
        • (filePath, type): 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, source) => string)
        • (destination, source): string
        • Create a system symbolic link. Throws an error if it encounters a filesystem problem.

          Parameters

          • destination: string
          • source: string

          Returns string

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

          Parameters

          • dir: string

          Returns boolean

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

          Parameters

          • file: string

          Returns boolean

    • removeLinkfileSafely: ((filePath) => string)
        • (filePath): 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>)
      • (params): 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) => {
        [key: string]: any;
    })
      • (response): {
            [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, b, arg?) => {
        [key: string]: any;
    })
      • (a, b, arg?): {
            [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) => boolean)
      • (o): boolean
      • Is the JS Object passed in truly just an object?

        Parameters

        • o: any

        Returns boolean

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

        • pid: number

        Returns boolean

  • parseCookies: ((req) => object)
      • (req): 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) => {
        ip: string;
        port: string | number;
    })
      • (headers): {
            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) => {
        host: string;
        port: number;
    })
      • (addr): {
            host: string;
            port: number;
        }
      • Parse an IPv6 address, returning both host and port. see https://github.com/actionhero/actionhero/issues/275

        Parameters

        • addr: string

        Returns {
            host: string;
            port: number;
        }

        • host: string
        • port: number
  • replaceDistWithSrc: ((f) => string)
      • (f): 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

  • safeGlobSync: ((match, args?) => string[])
      • (match, args?): string[]
      • Parameters

        • match: string
        • args: IOptions = {}

        Returns string[]

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

        Parameters

        • time: number

        Returns Promise<void>

  • sortGlobalMiddleware: ((globalMiddlewareList, middleware) => void)
      • (globalMiddlewareList, middleware): void
      • Sorts an Array of Objects with a priority key

        Parameters

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

        Returns void

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

        • linkFile: string
        • pluginPaths: string[]

        Returns string | boolean

Generated using TypeDoc