ActionHero Documentation - Overview
ActionHero Documentation - Overview
ActionHero is a node.js API framework for both tcp sockets, web sockets, and http clients. The goal of ActionHero is to create an easy-to-use toolkit for making reusable & scalable APIs. Clients connected to an ActionHero server can consume the API, consume static content, and communicate with each other.
ActionHero servers can process both requests and tasks (delayed actions like `send e-mail` or other background jobs). ActionHero servers can also run in a cluster (on the same or multiple machines) to work in concert to handle your load.
The ActionHero API defines a single access point and accepts GET, POST, PUT and DELETE input along with persistent connection via TCP or web sockets. You define Actions which handle input and response, such as `userAdd` or `geoLocate`. HTTP, HTTPS, and TCP clients can all use these actions. The ActionHero API is not inherently "RESTful" (which is meaningless for persistent socket connections) but can be extended to be so if you wish.
ActionHero will also serve static files for you, but ActionHero is not a 'rendering' server (like express or rails).
This documentation will always reflect the master branch of ActionHero, and therefore may be slightly ahead of the latest release on NPM.
Get started now:
mkdir ~/project && cd ~/project
npm install actionhero
npm installto install dependencies
http://127.0.0.1:8080 in your browser to see the ActionHero in action!
You can also opt to install ActionHero globally
npm install actionhero -g and then you can just call
The map to the right describes ActionHero's default project layout.
/actions will be loaded in automatically, along
/public will become your application's default static asset location.
If you wish to customize your project's paths, you can do so within
config/api.js in the
Want to see an example application using ActionHero? You can check out the code and follow the detailed guide here (https://github.com/actionhero/actionhero-tutorial). This project demonstrates many of the core features of ActionHero in a simple project.
cachetest: This action demonstrates how to handle parameter checking for an action, and how to use the internal cache methods of actionhero to save and recall data provided from a client.
randomNumber: This example shows how to craft a simple action with no input, but to respond differently to clients based on their HTTP method (if it exists)
status: This action will render some statistics about this ActionHero node, and all nodes in the cluster. Useful for health checks.
SimpleFileResponder: This action demonstrates how you can can manually send files from within actions.
JadefileResponder: This snippet is for rendering Jade templates on the server for pushState single page apps in ActionHero. Useful when you need to bootstrap model data on initial page load. It also pre-compiles the templates on server start and will recompile if they change.
oauth: This file is actually 2 actions which are needed to authenticate a user against twitter's API. Note the use of
api.cache to save and load the temporary secret tokens, and how to send custom (redirect) headers with ActionHero
Authentication Example: This example contains a working user system (auth, login, user creation, sessions, etc) using redis.
Tic-Tac-Toe API This advanced example demonstrates how to create actions (and initializers) which will enable you to play tic-tac-toe against an AI Player.
node via TCP: You can talk to an ActionHero server from another node project over TCP directly using this package.
node via HTTP/connect: ActionHero has a robust test suite for the web server which users connect.
Angular: You can connect to ActionHero via angular and connect via HTTP or WebSocket (actionheroWebSocket).
session: use the cache methods and
connection.id to easily make some session management helpers.
mongo: a MongoDB initializer
runAction: This (non periodic) task is used to call an action in the background. For example, you might have an action to
sendEmail which can be called synchronously by a client, but you also might want to call it in a delayed manner. This is the task for you!
sayHi A very simple example which will just log ‘HELLO' to the command line every 5 seconds.
cleanLogFiles: This periodic task will run on all servers and inspect ActionHero's
log directly for large log files, and delete them
pingSocketClients: This periodic task will run on all servers and send a ‘ping' to any connected TCP clients to help them keep their
ActionHero could not be possible with out the help of our community. Thank you all.
Join us on Slack to talk more about ActionHero!