question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Type Props for actions and tasks

See original GitHub issue

I’ll bet we can use inputs to learn the types of params for actions and tasks, and that would really help the developer experience!

Ideally:

import { Action } from 'actionhero'

export class UserView extends Action {
  constructor() {
    super();
    this.name = "user:view";
    this.description = "view the details of a user";
    this.outputExample = {};
    this.inputs = {
      guid: { required: true, type: string },
    };
  }

  async run({ params, response }) {
   // we should be able to know that `params` only has the property `guid` and is of type `string`
    const user = await User.findByGuid(params.guid);
    response.user = await user.formatForApi();
  }
}

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:13 (11 by maintainers)

github_iconTop GitHub Comments

1reaction
krlicmuhamedcommented, Jan 5, 2021

@krlicmuhamed Can you share example code to reproduce the error?

Here you go https://github.com/krlicmuhamed/apiauth

$ npm run build && npm run start 

> my_actionhero_project@0.1.0 build
> tsc --sourceMap false --declaration


> my_actionhero_project@0.1.0 start
> node ./dist/server.js

2021-01-05T15:25:54.820Z - alert: Failed to load C:/Projects/APIAUTH/dist/actions/classes/authenticatedAction.js stacktrace=Error: name is required for this action
    at AuthenticatedAction.validate (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\action.js:51:19)
    at Object.index_1.api.actions.loadFile (C:\Projects\APIAUTH\node_modules\actionhero\dist\initializers\actions.js:37:34)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Actions.initialize (C:\Projects\APIAUTH\node_modules\actionhero\dist\initializers\actions.js:68:17)
    at async Object.initializeFunction (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:101:29)
    at async Object.asyncWaterfall (C:\Projects\APIAUTH\node_modules\actionhero\dist\modules\utils\asyncWaterfall.js:47:23)
    at async Process.initialize (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:170:13)
    at async Process.start (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:179:13)
    at async main (C:\Projects\APIAUTH\dist\server.js:13:5)
2021-01-05T15:25:54.865Z - emerg: Exception occurred in initializer `actions` during load 
2021-01-05T15:25:54.867Z - emerg: Error with initializer step: "initialize"
2021-01-05T15:25:54.869Z - emerg: Error: name is required for this action
    at AuthenticatedAction.validate (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\action.js:51:19)
    at Object.index_1.api.actions.loadFile (C:\Projects\APIAUTH\node_modules\actionhero\dist\initializers\actions.js:37:34)
    at processTicksAndRejections (node:internal/process/task_queues:93:5)
    at async Actions.initialize (C:\Projects\APIAUTH\node_modules\actionhero\dist\initializers\actions.js:68:17)
    at async Object.initializeFunction (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:101:29)
    at async Object.asyncWaterfall (C:\Projects\APIAUTH\node_modules\actionhero\dist\modules\utils\asyncWaterfall.js:47:23)
    at async Process.initialize (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:170:13)
    at async Process.start (C:\Projects\APIAUTH\node_modules\actionhero\dist\classes\process.js:179:13)
    at async main (C:\Projects\APIAUTH\dist\server.js:13:5)
2021-01-05T15:25:54.904Z - crit: Cannot shut down actionhero, not running 
npm ERR! code 1
npm ERR! path C:\Projects\APIAUTH
npm ERR! command failed
npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node ./dist/server.js

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Muhamed\AppData\Local\npm-cache\_logs\2021-01-05T15_25_55_980Z-debug.log
1reaction
papbcommented, Nov 6, 2020

Pong! Sorry for the delay, I have been quite busy, but hopefully next week I will be able to help you. Sorry!!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Types of Props - IATSE Local 470
Hand props are anything handled or carried by an actor. They include staffs, food, weapons, lanterns and candles, canes, staffs, parasols, and practically ......
Read more >
Task List App — React and Redux with Typescript Part 2
Create components and dispatch actions. In src folder create components folder. Inside this folder create some components. Header.tsx
Read more >
Different Ways to Dispatch Actions with Redux - Pluralsight
No single option is considered the best, as it fully depends on our use case. Let's look at the various ways to dispatch...
Read more >
React interactivity: Events and state - Learn web development
In React, we write event handlers directly on the elements in our JSX, ... We want to pass props.tasks into the useState() hook...
Read more >
React with Typescript - Type { } is missing the following ...
As you are passing card to ProfileCard component, its passing 4 values in props. {login: string, name: string, key: number, id: number}.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found