ActionHero v23.0.0 Release Notes
Release Date: 2020-06-28 // almost 4 years ago-
What's New in v23 of Actionhero?
๐ Swagger API Documentation #1474
๐ For years, Actionhero has shipped with a
showDocumentation
action that provided a way to describe the actions running on your server. The action was used to self-document the abilities of your server. However, the format of that action was arbitrary... and not helpful in a larger ecosystem. Switching the format of this action to swagger/OpenAPI will make the Action much more useful!- ๐ Switch the
showDocumentation
action withswagger
action. Remove all old references toshowDocumentation
- Include a new
swagger.html
andswagger
action in generated projects which can consume and demo the API - โ Remove
initializer/documentation
, as we don't need this documentation internally without the old showDocumentation action.
๐ The breaking change is only around the
showDocumentation
anddocumentation
initializer, which appears to not be used very much.
๐ New Actionhero projects going forward will be generated with the Swagger Action and HTML page, which can be seen here https://demo.actionherojs.com/swagger.html๐ฒ Action and Task errors log on only one line #1505
๐ฒ Actions and tasks now log to one line in the file and other transports. The stack trace contains
\n
so it still is legible pretty in the console.Action
# Console2020-06-25T00:48:24.045Z - error: [action @ web] to=127.0.0.1 action=broken params={"action":"broken","apiVersion":1} duration=1 error=TypeError: Cannot read property 'missing' of undefined stacktrace=TypeError: Cannot read property 'missing' of undefined at ValidationTest.run (/Users/evan/workspace/actionhero/actionhero/src/actions/broken.ts:14:27) at ActionProcessor.runAction (/Users/evan/workspace/actionhero/actionhero/src/classes/actionProcessor.ts:378:35) at processTicksAndRejections (internal/process/task\_queues.js:97:5)# File{"to":"127.0.0.1","action":"broken","params":"{\"action\":\"broken\",\"apiVersion\":1}","duration":1,"error":"TypeError: Cannot read property 'missing' of undefined","stacktrace":"TypeError: Cannot read property 'missing' of undefined\n at ValidationTest.run (/Users/evan/workspace/actionhero/actionhero/src/actions/broken.ts:14:27)\n at ActionProcessor.runAction (/Users/evan/workspace/actionhero/actionhero/src/classes/actionProcessor.ts:378:35)\n at processTicksAndRejections (internal/process/task\_queues.js:97:5)\n at WebServer.processAction (/Users/evan/workspace/actionhero/actionhero/src/classes/server.ts:229:18)","level":"error","message":"[action @ web]","timestamp":"2020-06-25T00:48:24.045Z"}
Task
# Console2020-06-25T00:38:03.840Z - error: error from task: task:busted on queue default (worker #1) arguments=[object Object] stacktrace=Error: NOPE at MyTask.run (/Users/evan/workspace/actionhero/actionhero/src/tasks/busted.ts:14:11) at Worker.perform (/Users/evan/workspace/actionhero/actionhero/src/initializers/tasks.ts:123:39) at Worker.perform (/Users/evan/workspace/actionhero/actionhero/node\_modules/node-resque/dist/core/worker.js:165:41) at processTicksAndRejections (internal/process/task\_queues.js:97:5)# File{"name":"task:busted","queue":"default","worker":1,"arguments":"{}","stacktrace":"Error: NOPE\n at MyTask.run (/Users/evan/workspace/actionhero/actionhero/src/tasks/busted.ts:14:11)\n at Worker.perform (/Users/evan/workspace/actionhero/actionhero/src/initializers/tasks.ts:123:39)\n at Worker.perform (/Users/evan/workspace/actionhero/actionhero/node\_modules/node-resque/dist/core/worker.js:165:41)\n at processTicksAndRejections (internal/process/task\_queues.js:97:5)","level":"error","message":"error from task","timestamp":"2020-06-25T00:48:28.478Z"}
๐ฒ This PR also adds support for logging custom Error properties, ie:
import { api, Action } from "./../index";class AuthenticationError extends Error {code: string;constructor(message, code = "AUTHENTICATION\_ERROR") {super(message);this.code = code;}}export class ValidationTest extends Action {constructor() {super();this.name = "broken";this.description = "I am broken";this.inputs = {};this.outputExample = {};}async run({ params, response }) {throw new AuthenticationError(`broken`);}}
๐ฒ ... which will contain "code" in the log message along with the error.
๐ฒ Optionally log Action responses #1494
๐ฒ 2 new options now enable you to log the responses your actions send to consumers of your API
- 0๏ธโฃ
config.general.enableResponseLogging
(bool) toggles this option on (off by default) - ๐
config.general. filteredResponse
(string[]) allow you to filter out certain parts of the response payload from the logs, hiding sensitive data.
When using simpleRouting, the shown Swagger route is be GET #1506
๐ Trim protocol from allowedRequestHosts when building swagger routes #1495
And of course...
- โก๏ธ Update all dependencies to the latest versions.
โฌ๏ธ Upgrading to v23 of Actionhero
๐ This release is breaking for 2 reasons:
- The logger format for Action and Task errors has changed Pull Request.
๐ 2. The
Documentation
initializer and relatedshowDocumentation
action has been removed in favor of the new swagger action & middleware Pull Request.
โก๏ธ If you use automated log ingestion (i.e.: Splunk or a Winston logger) this PR should be helpful, as the error and stack trace will now all be on the same line... but you will need to update your log tools.
๐ If you had been using the
Documentation
middleware, you can re-build it yourself fromapi.actions.actions
. If you want upgrade your Actionhero project to use the new Swagger documentation tooling, you need to copy in 2 files:- The Swagger public page - swagger.html
- The Swagger Action - swagger.ts
๐ฒ There are also new logging options to add to
src/config/api.ts
:- 0๏ธโฃ
config.general.enableResponseLogging
(bool) toggles this option on (off by default) - ๐
config.general. filteredResponse
(string[]) allow you to filter out certain parts of the response payload from the logs, hiding sensitive data.
- ๐ Switch the