api

api

Source:
Properties:
Name Type Description
env string

The environment (usually sourced from process.env.NODE_ENV) the server is running in.

running Boolean

Is the process running?

initialized Boolean

Have we loded the initialize step of the initializers?

shuttingDown Boolean

Is the process in the middle of stopping?

projectRoot string

The path to the root of your project?

bootTime Date

The time this server was started?

id Number

The ID of this server. Can be set by argv.title, process.env.ACTIONHERO_TITLE, api.config.general.id. The default is using this server's external IP address and PID.

watchedFiles Array

Array of file which this server is monitoring and will act on if changed (Devloper Mode)

The top-level for all actionhero methods which can be used within your project.

Namespaces

actions
cache
chatRoom
config
connections
documentation
exceptions
i18n
id
params
pids
redis
resque
routes
servers
specHelper
staticFile
tasks
utils

Methods

(static) log(message, severity, data)

Source:
See:

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

Example
// the most basic use.  Will assume 'info' as the severity
api.log('hello');

// custom severity
api.log('OH NO!', 'warning');

// custom severity with a metadata object
api.log('OH NO, something went wrong', 'warning', { error: new Error('things are busted') });
Parameters:
Name Type Description
message string

The message to log.

severity string

(optional) What log-level should this message be logged at. Default: 'info'.

data Object

(optional) Any object you wish to append to this message.

(static) unWatchAllFiles()

Source:
See:

Stop watching all files previously watched via api.watchFileAndAct. Only availalbe in Development Mode.

(static) watchFileAndAct(file, callback)

Source:
See:

Monitor a file and call handler when it changes on disk. Only availalbe in Development Mode.

Parameters:
Name Type Description
file string

The name of the file to watch.

callback function

Method to call when the file changes. Callback will be passed the name of the changed file.