ActionHero v24.0.1 Release Notes

Release Date: 2020-10-26 // over 3 years ago
  • Prefer the end command when disconnecting from redis #1635

    With ioredis "quit" will try to reconnect now. We want to "end" the connections when shutting down.

    👀 If you are seeing timeouts when completing your jest tests or errors like Jest did not exit one second after the test run has completed. this may be the culprit

    Actions can be called in-line #1628

    This PR introduces action.run() which allows Actions to be run arbitrarily from elsewhere in the codebase. With this, you can have one Action call another, have a Task run Action, etc. Middleware for the the Action will be run. action.run() creates a new proxy connection with only the arguments you provide to the method.

    import { action } from "actionhero"const nameOfAction = 'myAction'const actionVersion = 'v1' // or leave null to use the latest versionconst params = {key: 'value'} // the params which would be parsed from the clientconst connectionProperties = {} // special properties on the connection which may be expected by the action or middleware. Perhaps "session.id" or "authenticated = true" depending on your middlewareconst response = await action.run(nameOfAction, actionVersion, params, connectionProperties);
    

    So, if you wanted an Action which combines the responses of 2 other Actions:

    import { Action, action } from "actionhero";export class RecursiveAction extends Action {constructor() {super();this.name = "recursiveAction";this.description = "I am an action that runs 2 other actions";this.outputExample = {};}async run() {const localResponse = { local: true };const firstActionResponse = await action.run("otherAction");const secondActionResponse = await action.run("anotherAction");return Object.assign(firstActionResponse, secondActionResponse, localResponse);}}
    

    Future work:

    • Type the responses of action.run() according the run method's return types.

    ⚡️ Update dependencies