Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't override default actions #53

Closed
diegogangl opened this issue Nov 3, 2023 · 0 comments
Closed

Can't override default actions #53

diegogangl opened this issue Nov 3, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@diegogangl
Copy link

I'm disabling the default actions with the following:

      createActions: {
        remove: false,
      },

Then I'm trying to override that remove action with a custom one like so:

    remove: {
      rest: {
        method: "DELETE",
        path: "/:id",
      },
      params: {
        id: {type: "string"},
      },
      async handler(ctx) {
              // ...
          });
        }
      },
    },

Unfortunately, this crashing with the following error:

TypeError: def.rest.replace is not a function

    at fixIDInRestPath (@moleculer\database\src\schema.js:32:23)
    at Service.merged (@moleculer\database\src\index.js:272:6)
    at node_modules\moleculer\src\service.js:87:35
    at Array.forEach (<anonymous>)
    at Service.parseServiceSchema (moleculer\src\service.js:87:18)
    at new Service (moleculer\src\service.js:64:20)
    at ServiceBroker.createService (node_modules\moleculer\src\service-broker.js:840:14)
    at ServiceBroker.loadService (moleculer\src\service-broker.js:805:16)
    at moleculer\src\middlewares\hot-reload.js:34:20
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

If I pass rest a simlpe string, it runs but it creates end points for every verb (GET, PUT, etc). Removing the rest setting makes the action dissapear. The only workaround I've found for now is to rename the action to something else, like safeRemove.

@icebob icebob added the bug Something isn't working label Nov 6, 2023
@icebob icebob closed this as completed in a20e5de Nov 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants