moleculerjs / moleculer-repl

REPL module for Moleculer framework
http://moleculer.services/docs/moleculer-repl.html
MIT License
27 stars 25 forks source link

Feature request: default meta #70

Closed morkeleb closed 1 year ago

morkeleb commented 1 year ago

I'd like to be able to set a default meta to be added to each request sent using the repl. This means I could start a repl and have all my action calls preloaded with for example user data.

Allowing me to more efficiently work with the repl impersonating one of my system users.

Suggested solution:

When I create my serviceBroker for a repl I could set an option for defaultMeta:

  const broker = await startBroker({ defaultMeta: { myMeta: 'test'} } );
  broker.repl()

Alternatively it could be passed as a parameter to the repl command, but having it available in options for the service just like everything else might be a more natural place to have it.

icebob commented 1 year ago

To cover it, you can create your custom commands where you can use any params, meta what you want, e.g.: https://github.com/icebob/kantab/blob/master/repl-commands/boards.js

morkeleb commented 1 year ago

That would work for us, so I will do that.

It would be nice to have it built in.