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 with swagger action. Remove all old references to showDocumentation
    • Include a new swagger.html and swagger 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.

    Screen Shot 2020-05-23 at 5 15 28 PM

    ๐Ÿ“š The breaking change is only around the showDocumentation and documentation 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.

    Screen Shot 2020-06-27 at 8 04 43 PM

    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:

    1. The logger format for Action and Task errors has changed Pull Request. ๐Ÿ“š 2. The Documentation initializer and related showDocumentation 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 from api.actions.actions. If you want upgrade your Actionhero project to use the new Swagger documentation tooling, you need to copy in 2 files:

    ๐ŸŒฒ 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.