@liteflow/service
Installation
npm install @liteflow/service
Service
const Service = require('@liteflow/service')
const liteflow = new Service()
Task
The service have to call liteflow.listenTask
to start listening for task to execute by passing an object containing the tasks' key and function.
liteflow.listenTask({
'TASK_1_KEY': (inputs) => {
if (inputs.foo === undefined) {
throw new Error('foo is undefined')
}
return { foo: inputs.a + 'bar' }
},
'TASK_2_KEY': async (inputs) => {
const response = await fetch('...')
return response.json()
},
})
The task functions accept inputs
as parameter and returns the outputs
as object or Promise of object.
The task function can throw an Error in case of error. The lib will catch it and send it to the MESG Engine.