# stepit

> create steps based process and simplify its design and development

Latest version **1.0.7** (published 2019-05-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install stepit
pnpm add stepit
yarn add stepit
bun add stepit
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.7 |
| Published | 2019-05-09 |
| First published | 2019-03-24 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | asco88 |

## Links

- npm: https://www.npmjs.com/package/stepit
- Repository: https://github.com/asco88/stepit
- Homepage: https://github.com/asco88/stepit#readme
- Issues: https://github.com/asco88/stepit/issues
- npm.io page: https://npm.io/package/stepit

## Recent versions

- 1.0.7 (latest) — 2019-05-09
- 1.0.6 — 2019-04-01
- 1.0.5 — 2019-03-30
- 1.0.4 — 2019-03-30
- 1.0.3 — 2019-03-29
- 1.0.2 — 2019-03-25
- 1.0.1 — 2019-03-24
- 1.0.0 — 2019-03-24

## README

# stepit

Creating a businness flow is as simple as defining it's business steps
Create simple steps to implement small tasks.
Create Workflow and attach the right steps
Manage express api using an existing Workflow


## Usage

Install the package using npm:

    npm install stepit --save

Example of usage with Express

	const { Workflow, Step } = require('stepit');

	app.post('/steps', (req, res) => {
	    const workflow = new Workflow();
	    const step = new Step('step', (done, data) => {
			// do some stuff
	        done();
	    });

	    workflow.addStep(step);
	    workflow.startWorkflow(req, res);
	})

The workflow final data is accessible theough Promise:

    const w = workflow.startWorkflow();
    w.then(result => {
        res.send(result);
    });


You can add mask for the response, each mask will be taken from data.variables straight into the response body

    const options = {
        responseBodyMask: ['user']
    }

    const workflow = new Workflow(options);
    const getUserStep = new Step('get-user', (done, data) => {

        const userid = data.request.params.userId;

        someUserFindingMethod(userid, (user) => {
        	data.variables = {...data.variables, user: clonedUser}
            done();
        })
    });

The response will contain the user as was added to data.variables

Each step can start a new 'subworkflow', it can be defined when creating new Step instance:

    workflow.addStep(new Step('step2', undefined, workflow2));

Or to be added explicitly:

    step.subWorkflow(workflow);

in both cases, the step itself will execute the workflow instead of any action of it's own



You can add as many steps as you like.
They will be executed in the same order they were added.
The Workflow guarantees a synchronous execution of each step after the previuos one

## License

ISC

---
_Source: https://npm.io/package/stepit · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
