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 run dev

> actionhero@21.0.6 dev /Users/evan/workspace/actionhero/actionhero
> ts-node-dev --transpile-only src/server.ts

Using ts-node version 8.5.2, typescript version 3.7.2
₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋₋
ACTIONHERO COMMAND >> start
⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻⁻
192.168.7.33 @ 2019-11-27T23:29:24.255Z - notice: pid: 70962
192.168.7.33 @ 2019-11-27T23:29:24.256Z - notice: environment: development
192.168.7.33 @ 2019-11-27T23:29:24.256Z - info: *** Starting ActionHero ***
192.168.7.33 @ 2019-11-27T23:29:24.258Z - info: actionhero member 192.168.7.33 has joined the cluster
192.168.7.33 @ 2019-11-27T23:29:24.261Z - notice: Starting server: 'web' @ 0.0.0.0:8080
192.168.7.33 @ 2019-11-27T23:29:24.262Z - notice: Starting server: 'websocket'
192.168.7.33 @ 2019-11-27T23:29:24.776Z - notice: server ID: 192.168.7.33
192.168.7.33 @ 2019-11-27T23:29:24.776Z - notice: *** ActionHero Started ***

Getting Started


Requirements

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

brew install node
brew install redis
brew services start redis # this will keep redis running in the background forever

# On Ubuntu:

(sudo) apt-get install node
(sudo) apt-get install redis-server
redis-server --daemonize yes # this will keep redis running in the background for this session

# On Windows:

[download nodeJS](https://nodejs.org/en/download)
[download redis](https://github.com/MSOpenTech/redis)
run redis.exe in a background window

Install and Quickstart


Get started now:

mkdir ~/project && cd ~/project
npx actionhero generate
npm install
# ensure redis is running; see above
npm dev
  • 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 dev

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. Actionhero does not support running from a global (system) location, and expects to be installed locally per-project. You can learn more about why here


Key Concepts


The next step is learning more about Actionhero's Key Concepts, Actions, Tasks, Initializers, Chat, and Servers, and how Actionhero differs from a traditional MVC-style framework.


Application Structure


|
|- src
|  - config
|    - (project settings)
|
|  - actions
|    -- (your actions)
|
|  - initializers
|    -- (any additional initializers you want)
|
|  - servers
|    -- (custom servers you may make)
|
|  - tasks
|    -- (your tasks)
|
|  - bin
|    -- (your custom CLI commands)
|
|- locales
|-- (translation files)
|
|- __tests__
|-- (tests for your API)
|
| - 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)
|
readme.md
package.json

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 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 main branch with any updates or changes.


Documentation Notes


This documentation will always reflect the main 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



Premium Training & Review


We provide support for corporate & nonprofit customers starting at a flat rate of $200/hr. Our services include:


  • Remote training for your team
  • Code Reviews
  • Best Practices Audits
  • Custom plugin & Feature Development

We have packages appropriate for all company sizes. Contact us to learn more.


Premium Training & Review


We provide support for corporate & nonprofit customers starting at a flat rate of $200/hr. Our services include:


  • Remote training for your team
  • Code Reviews
  • Best Practices Workshops
  • Custom plugin & Feature Development

We have packages appropriate for all company sizes. Contact us to learn more.


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.