[ 
https://issues.apache.org/jira/browse/CAMEL-18814?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Claus Ibsen updated CAMEL-18814:
--------------------------------
    Fix Version/s:     (was: 3.x)

> 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
>
> {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