Remove Simple Routing and Query Routing? #1579
-
Actionhero has 2 features aimed at making it easier to get up-and-running with new HTTP projects - // From config/servers/web.ts
// simple routing also adds an 'all' route which matches /api/:action for all actions. All includes GET, POST, PUT and DELETE
simpleRouting: true,
// queryRouting allows an action to be defined via a URL param, ie: /api?action=:action
queryRouting: true, However, these options (which are enabled by default in new projects) are confusing when considered alongside The negative side effect of removing Simple and Query Routing would be that you cannot view your actions on the web without first adding them to What do you think about removing Simple Routing and Query Routing from Actionhero? |
Beta Was this translation helpful? Give feedback.
Replies: 5 comments 8 replies
-
There would be some extra work needed to create a routes file for demo.actionherojs.com - running Actionhero directly and having an "internal" routes file. |
Beta Was this translation helpful? Give feedback.
-
Simple Routing ( That said, now that we have a real router, I could have just handled this all in |
Beta Was this translation helpful? Give feedback.
-
If we were going to remove this I'd like to see it replaced with something in the Action template. Perhaps like: class Status extends Action {
constructor() {
super();
this.name = "status";
this.description = "I will return some basic information about the API";
this.path = "status";
this.outputExample = {
id: "192.168.2.11",
actionheroVersion: "9.4.1",
uptime: 10469,
};
}
} Where |
Beta Was this translation helpful? Give feedback.
-
While I suppose a use case of having the same action available to multiple routes might be a valid one I just ran into this and had to disable it. i was finding all my actions in swagger under get and not with their correct verbs according to routes.js. I can't really opine too hard on if this feature should be yanked or not. At a minimum it should mentioned a little louder in https://www.actionherojs.com/tutorials/web-server#Config%20Options |
Beta Was this translation helpful? Give feedback.
-
@gcoonrod and I decided the path forward is:
# npx generate action --name userEdit
To enable your new action in the webserver, please add `{path: '/userEdit', action: 'userEdit'}` to `src/config/routes.ts` under the HTTP method of your choice.
|
Beta Was this translation helpful? Give feedback.
@gcoonrod and I decided the path forward is:
simpleRoutes
andqueryRoutes
- it's confusing and violates the principal of least surprise. Folks know aboutroutes.ts
and expect to use it.npx generate action
command will output a helpful hint like the following:src/config/routes.ts
to have all HTTP verbs expanded by default and include the example actions likestatus
.