Options
All
  • Public
  • Public/Protected
  • All
Menu

actionhero

Index

Modules

Classes

Interfaces

Variables

Functions

Object literals

Variables

Const PackageJSON

PackageJSON: any = require(path.join(__dirname,"..","..","..","package.json"))

Const actionheroVersion

actionheroVersion: any = packageJson.version

Const api

api: Api = new Api()

Const cluster

cluster: any = require("cluster")

Let config

config: ConfigInterface = buildConfig()

Const configPaths

configPaths: any[] = []

Let db

db: string = process.env.REDIS_DB || process.env.JEST_WORKER_ID || "0"

Const env

env: string = determineNodeEnv()

Let host

host: string = process.env.REDIS_HOST || "127.0.0.1"

Const id

id: string = determineId()

Let loggers

loggers: any[] = []

Const maxBackoff

maxBackoff: 1000 = 1000

Const maxEventLoopDelay

maxEventLoopDelay: string | 10 = process.env.eventLoopDelay || 10

Const maxMemoryAlloted

maxMemoryAlloted: string | 500 = process.env.maxMemoryAlloted || 500

Const maxResqueQueueLength

maxResqueQueueLength: string | 1000 = process.env.maxResqueQueueLength || 1000

Const options

options: any = config.i18n

Const os

os: any = require("os")

Const packageJSON

packageJSON: any = require(path.join(__dirname, "/../../../package.json"))

Const packageJson

packageJson: any = require(path.join(__dirname,"..","..","..","package.json"))

Let password

password: string = process.env.REDIS_PASSWORD || null

Const path

path: any = require("path")

Const pid

pid: number = process.pid

Let port

port: string | number = process.env.REDIS_PORT || 6379

Const projectRoot

projectRoot: string = determineProjectRoot()

Const taskModule

taskModule: task = task

Let title

title: string = sanitizeId()

Const typescript

typescript: boolean = isTypescript()

Const winston

winston: any = require("winston")

Functions

BOOT

  • BOOT(): Promise<void>

arrayStartingMatch

  • arrayStartingMatch(a: Array<any>, b: Array<any>): boolean

arrayUniqueify

  • arrayUniqueify(arr: Array<any>): Array<any>

asyncReadLink

  • asyncReadLink(file: string): Promise<string>

asyncStats

  • asyncStats(file: string): Promise<object>

asyncWaterfall

  • asyncWaterfall(jobs: Array<Function | object>): Promise<Array<any>>
  • In series, run an array of async functions

    without arguments

    let sleepyFunc = async () => {
      await new Promise((resolve) => { setTimeout(resolve, 100) })
      return (new Date()).getTime()
    }
    let jobs = [sleepyFunc, sleepyFunc, sleepyFunc]
    let responses = await api.utils.asyncWaterfall(jobs)
    // responses = [1506536188356, 1506536188456, 1506536188456]

    with arguments

    let sleepyFunc = async (response) => {
      await new Promise((resolve) => { setTimeout(resolve, 100) })
      return response
    }
    let jobs = [
      {method: sleepyFunc, args: ['a']},
      {method: sleepyFunc, args: ['b']},
      {method: sleepyFunc, args: ['c']}
    ]
    let responses = await api.utils.asyncWaterfall(jobs)
    // responses = ['a', 'b', 'c']

    Parameters

    • jobs: Array<Function | object>

    Returns Promise<Array<any>>

buildConfig

buildConsoleLogger

  • buildConsoleLogger(level?: string): (Anonymous function)
  • Parameters

    • Default value level: string = "info"

    Returns (Anonymous function)

buildFileLogger

  • buildFileLogger(path: any, level?: string, maxFiles?: any, maxsize?: number): (Anonymous function)
  • Parameters

    • path: any
    • Default value level: string = "info"
    • Default value maxFiles: any = undefined
    • Default value maxsize: number = 20480

    Returns (Anonymous function)

clearPidFile

  • clearPidFile(): void

collapseObjectToArray

  • collapseObjectToArray(obj: object): Array<any> | boolean

createDirSafely

  • createDirSafely(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

  • createFileSafely(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
    • Default value overwrite: boolean = false

    Returns string

createLinkfileSafely

  • createLinkfileSafely(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

  • createSymlinkSafely(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

determineId

  • determineId(): string

determineNodeEnv

  • determineNodeEnv(): string

determineProjectRoot

  • determineProjectRoot(): string

dirExists

  • dirExists(dir: string): boolean

ensureNoTsHeaderFiles

  • ensureNoTsHeaderFiles(files: Array<string>): Array<string>

eventLoopDelay

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

    Parameters

    • Default value itterations: number = 10000

    Returns Promise<number>

fileExists

  • fileExists(file: string): boolean

filterObjectForLogging

  • filterObjectForLogging(params: object): object
  • Prepares acton params for logging. Hides any sensitieve data as defined by api.config.general.filteredParams Truncates long strings via api.config.logger.maxLogStringLength

    Parameters

    • params: object

    Returns object

    • [key: string]: any

getExternalIPAddress

  • getExternalIPAddress(): string

hashMerge

  • hashMerge(a: object, b: object, arg?: object): object
  • Recursivley merge 2 Objects together. Will resolve functions if they are present, unless the parent Object has the propery _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 object

    • [key: string]: any

isPlainObject

  • isPlainObject(o: any): boolean

isTypescript

  • isTypescript(): boolean

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 default log levels are: 0=debug 1=info 2=notice 3=warning 4=error 5=crit 6=alert 7=emerg Learn more at https://github.com/winstonjs/winston

    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') })

    Parameters

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

    Returns void

parseCookies

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

    Parameters

    • req: object
      • headers: object
        • [key: string]: any

    Returns object

parseHeadersForClientAddress

  • parseHeadersForClientAddress(headers: object): object

parseIPv6URI

  • parseIPv6URI(addr: string): object

removeLinkfileSafely

  • removeLinkfileSafely(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

replaceDistWithSrc

  • replaceDistWithSrc(f: string): string
  • Used by generator functions running from your dist, it replacaes the path with your src Relies on api.config.general.paths

    Parameters

    • f: string

    Returns string

sanitizeId

  • sanitizeId(): string

sleep

  • sleep(time: number): Promise<void>

sortGlobalMiddleware

  • sortGlobalMiddleware(globalMiddlewareList: Array<any>, middleware: object): void

sortNumber

  • sortNumber(a: number, b: number): number

sourceRelativeLinkPath

  • sourceRelativeLinkPath(linkfile: string, pluginPaths: Array<string>): string | boolean

stringifyExtraMessagePropertiesForConsole

  • stringifyExtraMessagePropertiesForConsole(info: any): string

writePidFile

  • writePidFile(): void

Object literals

Const DEFAULT

DEFAULT: object

errors

  • errors(config: any): object
  • Parameters

    • config: any

    Returns object

    • _toExpand: boolean
    • connectionAlreadyInRoom: function
      • connectionAlreadyInRoom(connection: any, room: any): any
    • connectionNotInRoom: function
      • connectionNotInRoom(connection: any, room: any): any
    • connectionRoomAndMessage: function
      • connectionRoomAndMessage(connection: any): any
    • connectionRoomExists: function
      • connectionRoomExists(room: any): string
    • connectionRoomHasBeenDeleted: function
      • connectionRoomHasBeenDeleted(room: any): string
    • connectionRoomNotExist: function
      • connectionRoomNotExist(room: any): string
    • connectionRoomRequired: function
      • connectionRoomRequired(room: any): string
    • fileNotFound: function
      • fileNotFound(connection: any): any
    • fileNotProvided: function
      • fileNotProvided(connection: any): any
    • fileReadError: function
      • fileReadError(connection: any, error: any): any
    • genericError: function
      • genericError(data: any, error: any): Promise<any>
    • invalidParams: function
      • invalidParams(data: any, validationErrors: any): any
    • missingParams: function
      • missingParams(data: any, missingParams: any): any
    • serverShuttingDown: function
      • serverShuttingDown(data: any): any
    • tooManyPendingActions: function
      • tooManyPendingActions(data: any): any
    • unknownAction: function
      • unknownAction(data: any): any
    • unsupportedServerType: function
      • unsupportedServerType(data: any): any
    • verbNotAllowed: function
      • verbNotAllowed(connection: any, verb: any): any
    • verbNotFound: function
      • verbNotFound(connection: any, verb: any): any
    • serializers: object
      • servers: object

general

  • general(config: any): object
  • Parameters

    • config: any

    Returns object

    • apiVersion: any
    • cachePrefix: string
    • channel: string
    • cliIncludeInternal: boolean
    • defaultMiddlewarePriority: number
    • developmentMode: boolean
    • developmentModeForceRestart: boolean
    • directoryFileType: string
    • disableParamScrubbing: boolean
    • enforceConnectionProperties: boolean
    • fileRequestLogLevel: string
    • filteredParams: undefined[]
    • legacyApiPolyfill: boolean
    • lockDuration: number
    • lockPrefix: string
    • missingParamChecks: string[]
    • rpcTimeout: number
    • serverName: any
    • serverToken: string
    • simultaneousActions: number
    • startingChatRooms: object
    • paths: object
      • action: any[]
      • cli: any[]
      • dist: any
      • initializer: any[]
      • locale: any[]
      • log: any[]
      • pid: any[]
      • plugin: any[]
      • public: any[]
      • server: any[]
      • src: any
      • task: any[]
      • test: any[]

i18n

  • i18n(config: any): object
  • Parameters

    • config: any

    Returns object

    • defaultLocale: string
    • determineConnectionLocale: string
    • fallbacks: object
    • locales: string[]
    • objectNotation: boolean
    • updateFiles: boolean

logger

  • logger(config: any): object
  • Parameters

    • config: any

    Returns object

    • loggers: any[]
    • maxLogStringLength: number

plugins

  • plugins(config: any): object

redis

  • redis(config: any): object
  • Parameters

    • config: any

    Returns object

    • _toExpand: boolean
    • enabled: boolean
    • client: object
      • args: object[]
      • buildNew: boolean
      • konstructor: any
    • subscriber: object
      • args: object[]
      • buildNew: boolean
      • konstructor: any
    • tasks: object
      • args: object[]
      • buildNew: boolean
      • konstructor: any

routes

  • routes(config: any): object

tasks

  • tasks(config: any): object
  • Parameters

    • config: any

    Returns object

    • checkTimeout: number
    • maxEventLoopDelay: number
    • maxTaskProcessors: number
    • minTaskProcessors: number
    • queues: string[]
    • scheduler: boolean
    • stuckWorkerTimeout: number
    • timeout: number
    • connectionOptions: object
      • tasks: object
    • resque_overrides: object
      • multiWorker: null
      • queue: null
      • scheduler: null
    • schedulerLogging: object
      • end: string
      • enqueue: string
      • poll: string
      • reEnqueue: string
      • start: string
      • transferred_job: string
      • working_timestamp: string
    • workerLogging: object
      • cleaning_worker: string
      • end: string
      • failure: string
      • internalError: string
      • job: string
      • multiWorkerAction: string
      • pause: string
      • poll: string
      • start: string
      • success: string

servers

servers: object

web

  • web(config: any): object
  • Parameters

    • config: any

    Returns object

    • allowedRequestHosts: string[]
    • bindIP: string
    • bootAttempts: number
    • compress: boolean
    • enableEtag: boolean
    • enabled: boolean
    • flatFileCacheDuration: number
    • padding: number
    • port: string | number
    • queryParseOptions: object
    • queryRouting: boolean
    • returnErrorCodes: boolean
    • rootEndpointType: string
    • saveRawBody: boolean
    • secure: boolean
    • serverOptions: object
    • simpleRouting: boolean
    • urlPathForActions: string
    • urlPathForFiles: string
    • fingerprintOptions: object
      • cookieKey: string
      • onlyStaticElements: boolean
      • toSetCookie: boolean
      • settings: object
        • expires: number
        • path: string
    • formOptions: object
      • keepExtensions: boolean
      • maxFieldsSize: number
      • maxFileSize: number
      • uploadDir: any
    • httpHeaders: object
      • Access-Control-Allow-Headers: string
      • Access-Control-Allow-Methods: string
      • Access-Control-Allow-Origin: string
      • Strict-Transport-Security: string
      • X-Powered-By: any
    • metadataOptions: object
      • requesterInformation: boolean
      • serverInformation: boolean

websocket

  • websocket(config: any): object
  • Parameters

    • config: any

    Returns object

    • clientJsName: string
    • clientJsPath: string
    • clientUrl: string
    • destroyClientsOnShutdown: boolean
    • enabled: boolean
    • server: object
    • client: object
      • apiPath: string
      • cookieKey: any

Const production

production: object

general

  • general(config: any): object
  • Parameters

    • config: any

    Returns object

    • developmentMode: boolean
    • fileRequestLogLevel: string

servers

servers: object

web

  • web(config: any): object
  • Parameters

    • config: any

    Returns object

    • padding: null
    • metadataOptions: object
      • requesterInformation: boolean
      • serverInformation: boolean

Const test

test: object

general

  • general(config: any): object
  • Parameters

    • config: any

    Returns object

    • developmentMode: boolean
    • rpcTimeout: number
    • serverToken: string
    • paths: object
      • locale: any[]
    • startingChatRooms: object
      • defaultRoom: object
      • otherRoom: object

logger

  • logger(config: any): object

tasks

  • tasks(config: any): object
  • Parameters

    • config: any

    Returns object

    • checkTimeout: number
    • timeout: number

servers

servers: object

web

  • web(config: any): object
  • Parameters

    • config: any

    Returns object

    • matchExtensionMime: boolean
    • port: string | number
    • secure: boolean
    • metadataOptions: object
      • requesterInformation: boolean
      • serverInformation: boolean

Const utils

utils: object

Utility functions for Actionhero

arrayStartingMatch

arrayStartingMatch: arrayStartingMatch

arrayUniqueify

arrayUniqueify: arrayUniqueify

asyncWaterfall

asyncWaterfall: asyncWaterfall

collapseObjectToArray

collapseObjectToArray: collapseObjectToArray

ensureNoTsHeaderFiles

ensureNoTsHeaderFiles: ensureNoTsHeaderFiles

eventLoopDelay

eventLoopDelay: eventLoopDelay

filterObjectForLogging

filterObjectForLogging: filterObjectForLogging

getExternalIPAddress

getExternalIPAddress: getExternalIPAddress

hashMerge

hashMerge: hashMerge

isPlainObject

isPlainObject: isPlainObject

parseCookies

parseCookies: parseCookies

parseHeadersForClientAddress

parseHeadersForClientAddress: parseHeadersForClientAddress

parseIPv6URI

parseIPv6URI: parseIPv6URI

replaceDistWithSrc

replaceDistWithSrc: replaceDistWithSrc

sleep

sleep: sleep

sortGlobalMiddleware

sortGlobalMiddleware: sortGlobalMiddleware

sourceRelativeLinkPath

sourceRelativeLinkPath: sourceRelativeLinkPath

fileUtils

fileUtils: object

createDirSafely

createDirSafely: createDirSafely

createFileSafely

createFileSafely: createFileSafely

createLinkfileSafely

createLinkfileSafely: createLinkfileSafely

createSymlinkSafely

createSymlinkSafely: createSymlinkSafely

dirExists

dirExists: dirExists

fileExists

fileExists: fileExists

removeLinkfileSafely

removeLinkfileSafely: removeLinkfileSafely

Generated using TypeDoc