Let's get Started


Who is the ActionHero?


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).

> npm start

> [email protected] start /app/actionhero
> node ./bin/actionhero

info: actionhero >> start
2015-11-14 16:01:27 - notice: *** starting actionhero ***
2015-11-14 16:01:27 - info: actionhero member 10.0.1.15 has joined the cluster
2015-11-14 16:01:27 - notice: pid: 36087
2015-11-14 16:01:27 - notice: server ID: 10.0.1.15
2015-11-14 16:01:27 - info: ensuring the existence of the chatRoom: defaultRoom
2015-11-14 16:01:27 - info: ensuring the existence of the chatRoom: anotherRoom
2015-11-14 16:01:27 - notice: starting server: web
2015-11-14 16:01:27 - notice: starting server: websocket
2015-11-14 16:01:28 - notice: environment: development
2015-11-14 16:01:28 - notice: *** Server Started @ 2015-11-14 16:01:28 ***

Getting Started


Requirements

  • node.js ( >= v4.0.0)
  • npm
  • redis (for cluster support, cache, stats, and tasks); but not required.
# On OSX With Homebrew:

brew install node
brew install redis

# On Ubuntu:

(sudo) apt-get install node
(sudo) apt-get install redis-server

# On Windows:

[download nodeJS](https://nodejs.org/en/download)
[download redis](https://github.com/MSOpenTech/redis)

Install and Quickstart


Get started now:

mkdir ~/project && cd ~/project
npm install actionhero
npx actionhero generate
npm install
npm start
  • Create a new directory mkdir ~/project && cd ~/project
  • Checkout the ActionHero source npm install actionhero
  • Use the generator to create a template project npx actionhero generate
  • npm install to install dependencies
  • You can now start up the server: npm start

Visit http://127.0.0.1:8080 in your browser to see the ActionHero in action!

Do not install ActionHero globally with `npm install -g`


Application Structure


# ActionHero Project Layout

|- config
| -- api.js
| -- errors.js
| -- i18n.js
| -- logger.js
| -- redis.js
| -- routes.js
| -- tasks.js
| -- servers
| ---- web.js
| ---- websocket.js
| ---- socket.js
|-- (project settings)
|
|- actions
|-- (your actions)
|
|- initializers
|-- (any additional initializers you want)
|
|- log
|-- (default location for logs)
|
|- node_modules
|-- (your modules, ActionHero should be npm installed in here)
|
|- pids
|-- (pidfiles for your running servers)
|
|- public
|-- (your static assets to be served by /file)
|
|- servers
|-- (custom servers you may make)
|
|- tasks
|-- (your tasks)
|
|- locales
|-- (translation files)
|
|- tests
|-- (tests for your API)
|
readme.md
package.json (be sure to include 'actionhero':'x')

The map to the right describes ActionHero's default project layout.

Actions in /actions will be loaded in automatically, along /initializers and /tasks.

/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 api.config.general.paths section.


Tutorial


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.


Contributing


The www.actionherojs.com website and documentation is hosted on Heroku, and built from this codebase. You can submit pull requests to the master branch with any updates or changes.


Documentation Notes


This documentation will always reflect the master branch of ActionHero, and therefore may be slightly ahead of the latest release on NPM.

Solutions

ActionHero was built from the ground up to include all the features you expect from a modern API framework.

Open Source


The ActionHero server is open source, under the Apache-2 license


ActionHero runs on Linux, OS X, and Windows


You always have access to the ActionHero team via Slack and Github



Enterprise


For larger customers in need of a support contract, we offer an enterprise plan including everything in the Premium plan plus:


  • 24/7 access to core members of the ActionHero Team
  • Emergency response packages
  • Deployment support
  • ...and custom development against Actionhero’s core as needed.