[ 
https://issues.apache.org/jira/browse/CAMEL-18814?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17741465#comment-17741465
 ] 

Claus Ibsen commented on CAMEL-18814:
-------------------------------------

camel run https://gist.github.com/hguerrero/7757de49e4eb3f8c96e3e3756ddf02f9

> camel-javascript - Make it easier to interop Camel Message with JS functions
> ----------------------------------------------------------------------------
>
>                 Key: CAMEL-18814
>                 URL: https://issues.apache.org/jira/browse/CAMEL-18814
>             Project: Camel
>          Issue Type: Improvement
>            Reporter: Claus Ibsen
>            Priority: Major
>             Fix For: 3.x
>
>
> {code}
> // camel-k: language=js
> import { faker } from "./js/node_modules/@faker-js/faker/dist/esm/index.mjs";
> const greet = (exchange, message, headers, body) => {
>   return { hello: faker.name.fullName() };
> };
> const greetByName = (exchange, message, headers, body) => {
>   return { hello: headers.name };
> };
> const call = (e, callback) => {
>   const result = callback(
>     e,
>     e.getMessage(),
>     e.getMessage().getHeaders(),
>     e.getMessage().getBody()
>   );
>   e.getOut().setBody(result);
> };
> from("direct:greet").process((e)=>call(e, greet)).marshal().json();
> from("direct:greetByName").process((e)=>call(e,greetByName)).marshal().json();
> {code}
> I would like `process` to fire the call to a js function with all the params 
> (Exchange, Message, Headers, Body) and accept the result as is
> instead of having manually to do it, like in the call function
> Is there a way to include this call function as part of the process DSL or 
> even better add a new js process version?



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to