Options
All
  • Public
  • Public/Protected
  • All
Menu

actionhero

Index

Type aliases

ActionheroLogLevel

ActionheroLogLevel: "emerg" | "alert" | "crit" | "error" | "warning" | "notice" | "info" | "debug"

ExceptionReporter

ExceptionReporter: (error: NodeJS.ErrnoException, type: string, name: string, objects?: any, severity?: ActionheroLogLevel) => void

Type declaration

    • (error: NodeJS.ErrnoException, type: string, name: string, objects?: any, severity?: ActionheroLogLevel): void
    • Parameters

      • error: NodeJS.ErrnoException
      • type: string
      • name: string
      • Optional objects: any
      • Optional severity: ActionheroLogLevel

      Returns void

PluginConfig

PluginConfig: {}

Type declaration

  • [name: string]: PluginConfigRecord

RouteMethod

RouteMethod: typeof routerMethods[number]

RouteType

RouteType: { action: string; apiVersion?: number | string; dir?: string; matchTrailingPathParts?: boolean; path: string }

Type declaration

  • action: string
  • Optional apiVersion?: number | string
  • Optional dir?: string
  • Optional matchTrailingPathParts?: boolean
  • path: string

RoutesConfig

RoutesConfig: Partial<Record<typeof routerMethods[number], RouteType[]>>

Variables

actionheroVersion

actionheroVersion: string = packageJson.version

api

api: Api = globalThis.api

config

config: Partial<ActionheroConfigInterface> = ...

env

env: string = ...

id

id: string = ...

loggers

loggers: winston.Logger[] = []

projectRoot

projectRoot: string = ...

typescript

typescript: boolean = ...

utils

utils: { argv: {}; 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>) => {}; getExternalIPAddress: () => string; hashMerge: (a: Record<string, any>, b: Record<string, any>, arg?: Record<string, any>) => {}; isPlainObject: (o: any) => boolean; isRunning: (pid: number) => boolean; parseCookies: (req: { headers: {} }) => 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: {}) => void; sourceRelativeLinkPath: (linkFile: string, pluginPaths: string[]) => string | boolean } = ...

Utility functions for Actionhero

Type declaration

  • argv: {}
    • [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>) => {}
      • (response: Record<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
  • 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>) => {}
      • (a: Record<string, any>, b: Record<string, any>, arg?: Record<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
  • 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: {} }) => object
      • (req: { headers: {} }): object
      • Transform the cookie headers of a node HTTP req Object into a hash.

        Parameters

        • req: { headers: {} }
          • headers: {}
            • [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: {}) => 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 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

    Returns void

Generated using TypeDoc