3.0.0 • Published 3 years ago

@liteflow/service v3.0.0

Weekly downloads
20
License
ISC
Repository
github
Last release
3 years ago

@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) => {
    // Function of the task 1
    // Can directly throw error
    if (inputs.foo === undefined) {
      throw new Error('foo is undefined')
    }
    // Return an object
    return { foo: inputs.a + 'bar' }
  }, 
  'TASK_2_KEY': async (inputs) => {
    // Function of the task 2
    // Return an Promise containing an object
    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.

3.0.0

3 years ago

2.1.1

4 years ago

2.1.0

4 years ago

2.1.0-alpha.0

4 years ago

2.0.0

4 years ago

1.2.0-alpha.0

4 years ago

1.1.0

4 years ago

1.0.7

4 years ago

1.0.6

4 years ago

1.0.5

4 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

1.0.0-alpha.5

4 years ago

1.0.0-alpha.4

4 years ago

1.0.0-alpha.3

4 years ago

1.0.0-alpha.2

4 years ago

1.0.0-alpha.1

4 years ago