https://github.com/sammarks/workflow
A node package for executing simple workflows with rollback support.
https://github.com/sammarks/workflow
node rollback-support step step-functions typescript workflows
Last synced: about 1 month ago
JSON representation
A node package for executing simple workflows with rollback support.
- Host: GitHub
- URL: https://github.com/sammarks/workflow
- Owner: sammarks
- License: mit
- Created: 2019-07-24T21:04:47.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2024-02-25T18:14:21.000Z (over 1 year ago)
- Last Synced: 2024-10-19T01:15:15.579Z (7 months ago)
- Topics: node, rollback-support, step, step-functions, typescript, workflows
- Language: TypeScript
- Homepage: https://sammarks.github.io/workflow/
- Size: 348 KB
- Stars: 0
- Watchers: 2
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: code-of-conduct.md
Awesome Lists containing this project
README
![][header-image]
[](https://github.com/prettier/prettier)

[](https://coveralls.io/github/sammarks/workflow)
[](https://david-dm.org/sammarks/workflow?type=dev)
[](https://paypal.me/sammarks15)`workflow` is a Node JS library designed to facilitate the execution of simple workflows with
rollback support. This allows you to take small units of code and combine them together into
a larger workflow to accomplish a single large task.See [the documentation](https://sammarks.github.io/workflow/) for more details.
## Get Started
```sh
npm install @sammarks/workflow
yarn add @sammarks/workflow
``````typescript
import { execute } from '@sammarks/workflow'interface WorkflowContext {
firstStepRun: boolean
secondStepRun: boolean
test: string
}const workflow = [
{
name: 'first',
run: async (context: WorkflowContext): Promise => {
context.firstStepRun = true
},
revert: async (context: WorkflowContext): Promise => {
context.firstStepRun = false
}
},
{
name: 'second',
run: async (context: WorkflowContext): Promise => {
context.secondStepRun = true
},
revert: async (context: WorkflowContext): Promise => {
context.secondStepRun = false
}
}
]const result = await execute('test-workflow', workflow, { test: 'foo' })
console.log(result)// {
// firstStepRun: true,
// secondStepRun: true,
// test: 'foo'
// }
```## Features
- Define steps in a simple, typed, array-object format.
- Steps and workflows are given names for debugging support.
- Rollback support in case a step fails.
- Predictable and documented error handling in case something goes wrong.## Why use this?
Breaking the large task into smaller units of code allows a less complicated end result, and greater
unit testing abilities since each step in the workflow is broken into its own function.Rollback support allows a transactional nature for executing workflows. If one step in the process
fails to execute, all previously-executed steps with a configured rollback are executed.`workflow` provides TypeScript hinting and a predictable error interface to handle issues when they
arise.[header-image]: https://raw.githubusercontent.com/sammarks/art/master/workflow/header.jpg