Options
All
  • Public
  • Public/Protected
  • All
Menu

actionhero

Index

Type aliases

AssertEqualType

AssertEqualType<T, Expected>: T extends Expected ? Expected extends T ? true : FailingTypeMatchAssertion : FailingTypeMatchAssertion

Type parameters

  • T

  • Expected

ExceptionReporter

ExceptionReporter: (error: Error, type: string, name: string, objects?: any, severity?: string) => void

Type declaration

    • (error: Error, type: string, name: string, objects?: any, severity?: string): void
    • Parameters

      • error: Error
      • type: string
      • name: string
      • Optional objects: any
      • Optional severity: string

      Returns void

UnwrapPromise

UnwrapPromise<T>: T extends Promise<infer U> ? U : T extends (...args: any) => Promise<infer U> ? U : T extends (...args: any) => infer U ? U : T

Type parameters

  • T

Variables

Const actionheroVersion

actionheroVersion: string = ...

Const api

api: Api = ...

Const config

config: ConfigInterface = ...

Const env

env: string = ...

Const id

id: string = ...

Let loggers

loggers: winston.Logger[] = []

Const projectRoot

projectRoot: string = ...

Const typescript

typescript: boolean = ...

Const utils

utils: { arrayStartingMatch: (a: any[], b: any[]) => boolean; arrayUnique: (arr: any[]) => any[]; collapseObjectToArray: (obj: object) => any[] | boolean; ensureNoTsHeaderFiles: (files: string[]) => string[]; eventLoopDelay: (iterations?: number) => Promise<number>; fileUtils: { createDirSafely: (dir: string) => string; createFileSafely: (file: string, data: string, 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: object) => {}; filterResponseForLogging: (response: object) => {}; getExternalIPAddress: () => string; hashMerge: (a: object, b: object, arg?: object) => {}; isPlainObject: (o: any) => boolean; parseCookies: (req: { headers: {} }) => object; parseHeadersForClientAddress: (headers: object) => { ip: string; port: number }; parseIPv6URI: (addr: string) => { host: string; port: number }; replaceDistWithSrc: (f: string) => string; sleep: (time: number) => Promise<void>; sortGlobalMiddleware: (globalMiddlewareList: any[], middleware: {}) => void; sourceRelativeLinkPath: (linkfile: string, pluginPaths: string[]) => string | boolean } = ...

Utility functions for Actionhero

Type declaration

  • 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: object) => any[] | boolean
      • (obj: object): any[] | boolean
      • Collapses an Object with numerical keys (like arguments in a function) to an Array

        Parameters

        • obj: object

        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, 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, overwrite?: boolean) => string
        • (file: string, data: string, 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
          • 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: object) => {}
      • (params: object): {}
      • 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: object

        Returns {}

        • [key: string]: any
  • filterResponseForLogging: (response: object) => {}
      • (response: object): {}
      • 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: object

        Returns {}

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

        Returns string

  • hashMerge: (a: object, b: object, arg?: object) => {}
      • (a: object, b: object, arg?: object): {}
      • 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: object
        • b: object
        • Optional arg: object

        Returns {}

        • [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

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

        Parameters

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

        Returns object

  • parseHeadersForClientAddress: (headers: object) => { ip: string; port: number }
      • (headers: object): { ip: string; port: number }
      • Return ip and port information if defined in the header

        Parameters

        • headers: object

        Returns { ip: string; port: number }

        • ip: string
        • port: 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: {}) => void
      • (globalMiddlewareList: any[], middleware: {}): void
      • Sorts an Array of Objects with a priority key

        Parameters

        • globalMiddlewareList: any[]
        • middleware: {}
          • [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

Functions

log

  • log(message: string, severity?: string, data?: any): void
  • Log a message, with optional metadata. The message can be logged to a number of locations (stdio, files, etc) as configured via config/logger.js

    The most basic use. Will assume 'info' as the severity: log('hello') Custom severity: log('OH NO!', 'warning') Custom severity with a metadata object: log('OH NO, something went wrong', 'warning', { error: new Error('things are busted') })

    The default log levels are: emerg: 0, alert: 1, crit: 2, error: 3, warning: 4, notice: 5, info: 6, debug: 7. Logging levels in winston conform to the severity ordering specified by RFC5424: severity of all levels is assumed to be numerically ascending from most important to least important. Learn more at https://github.com/winstonjs/winston

    Parameters

    • message: string
    • severity: string = "info"
    • Optional data: any

    Returns void

Generated using TypeDoc