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 thecwd
(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 justnpm 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 firstcd
-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
ortask
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 theerror 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