ActionHero v20.0.0 Release Notes

Release Date: 2019-10-07 // over 4 years ago
  • Always prefer actionhero in node_modules

    ๐Ÿ”Œ Related to actionhero/ah-swagger-plugin#6

    We have changed how Actionhero loads itself to always prefer components in node_modules relative to the cwd (current working directory):

    Pros

    • There is no change to the behavior or a normal actionhero project
    • Globally installed Actionhero (npm install -g actionhero) is now resistant to minor version changes between projects
    • ๐Ÿ‘ Allows plugins to install a version of actionhero as a devDependancy, and for us to boot the project and not have conflicting paths to source actionhero from. You can now just npm start (./node_modules/.bin/actionhero) in your plugins to start a server to run your plugins

    Cons

    • If you start actoinhero from a dameon (like forever) without first cd-ing to the proper directory first things might not work depending on your load paths.
    • Slightly slower boot time (as we are checking if files exist before trying to load them).
    • Things (may) weird with yarn/lerna workspaces

    This is a breaking change

    Via #1338

    โœ… Create tests for actions and tasks when generating via CLI

    Completes #1005

    โœ… When generating a new action or task via the CLI, a template test will also now be creates in __tests__. This will help encourage better testing of your actionhero projects. Of course, you can always delete the test files if you don't want it.

    Adds api.config.general.paths.test as setting in ./config/api.js which defaults to [path.join( __dirname, '/../__ tests__')]

    This is a breaking change due to the new path

    Via #1332

    โž• Add custom http status code with error object

    Currently, we have to add the custom error response code like this:
    data.connection.rawConnection.responseHttpCode = 404
    We can use the error.code that already exists in the error object

    Now in action, you can do something like this :

    const raiseNotFound = \<your-condition\>if(raiseNotFound) { const notFoundError = new Error(\<msg\>) notFoundError.code = 404throw notFoundError }
    

    via #1334

    findEnqueuedTasks

    โž• Adds api.specHelper.findEnqueuedTasks to write tests that check that task was enqueued!

    describe('task testing', () =\> { beforeEach(async () =\> { await api.resque.queue.connection.redis.flushdb() }) test('detect that a task was enqueued to run now', async () =\> { await api.tasks.enqueue('regularTask', { word: 'testing' }) const found = await api.specHelper.findEnqueuedTasks('regularTask') expect(found.length).toEqual(1) expect(found[0].args[0].word).toEqual('testing') expect(found[0].timestamp).toBeNull() }) })
    

    via #1331

    Misc

    • โœ… Testing Actionhero should be less flaky now!
      • CircleCI fixes (via #1328)
      • When possible, start tests with a clean redis DB (via #1333)
      • Ensure we are running in NODE_ENV=test (via #1336)