Closed abdavid closed 4 years ago
I've just released 0.6.4 which supports defining meta keys with #
.
E.g:
moleculer λ call greeter.echo --load test.json --#user John
The user: "John"
will be placed into the ctx.meta
.
What if the meta
object is more complicated than a simple key/value pair? In my services, I pass in an authentication object which is relatively nested in meta
. Would love to define it in the json
file. It would be nice if the file could just have this structure:
{
"params" : {...},
"meta": {...}
}
@ujwal-setlur that's not currently possible but definitely doable. If you want to add a support for this you need to add a flag for this kind command over here: https://github.com/moleculerjs/moleculer-repl/blob/3fdf64c0f005cc5cbde47a2efac9a975652a110f/src/commands/call.js#L132-L144
and then in the actual handler add the parsing logic. For example, this is how params are currently being loaded from a file:
A PR with this would be nice :slightly_smiling_face:
What if the
meta
object is more complicated than a simple key/value pair? In my services, I pass in an authentication object which is relatively nested inmeta
. Would love to define it in thejson
file. It would be nice if the file could just have this structure:{ "params" : {...}, "meta": {...} }
@ujwal-setlur Added in https://github.com/moleculerjs/moleculer-repl/pull/61
https://github.com/moleculerjs/moleculer-repl/blob/e78ee19f831fdd85fc8e6783534db4e3f80c2cb7/src/commands/call.js#L127
I also tried adding meta to the params file, and looking at the code for the call command, it does not look like meta is supported when loading params from file.