# refab

> A Middleware pipeline framework Allows you to load an array of middleware and then run as a pipeline

Latest version **0.0.1** (published 2017-01-30) · UNLICENSED license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.1 |
| Published | 2017-01-30 |
| First published | 2017-01-30 |
| Weekly downloads | 0 |
| License | UNLICENSED |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | dirwin517 |
| Maintainers | dirwin517 |
| Keywords | pipeline, workflow, middleware, loader |

## Links

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

## Alternatives

- [byte-size](https://npm.io/package/byte-size.md) — 2.1M weekly downloads
- [speed-limiter](https://npm.io/package/speed-limiter.md) — 16.0K weekly downloads
- [@powersync/node](https://npm.io/package/@powersync/node.md) — 10.9K weekly downloads
- [@ledgerhq/coin-cardano](https://npm.io/package/@ledgerhq/coin-cardano.md) — 1.0K weekly downloads
- [@jayesol/jayeson.lib.streamfinder](https://npm.io/package/@jayesol/jayeson.lib.streamfinder.md) — 1.0K weekly downloads

## Recent versions

- 0.0.1 (latest) — 2017-01-30

## README

# refab
A Middleware pipeline framework
Allows you to load an array of middleware and then run as a pipeline

#Install
 
    npm install refab --save
    
#Usage with Loader

    var Loader = require('refab').Loader;

    var funcMiddleware = {
        func : function cycle(context, response, next) {
            console.log('func');
            context.func = 'happened';
            response.ok('finished');
        }
    }
                                 
    var middlewareByPath = {
       path : 'thing1'
    }

    var middlewareByRequire = {
       require : './test/thing2'
    }
    
    var sharedContext = {
        initData : 'started'
    }
    
    var responseObjects = {
         ok : function ok(data){
            console.log('ok', data);
            done()
        }
    }
    
    // timeout only happens if next or response is not called within time
    // final only gets called if
    //      a. Timeout
    //      b. next is called till no more middleware
    // continueOnTimeout (default false) if true calls next on timeout
    //
    var pipeline = Loader({
        timeout : 1000,
        continueOnTimeout : false
    }, [
            funcMiddleware,
            middlewareByPath,
            middlewareByRequire
    ]);
    
    pipeline(sharedContext,
     responseObjects,
      function final(context){
        console.log('context', context);
    });
   
#Usage w/o Loader

    var Runner = require('refab').Runner;

    var allMiddleware = [
        function cycle1(context, response, next) {
            
        },
        function cycle2(context, response, next) {
            
        },
        function cycle3(context, response, next) {
            
        }
    ]
                                 
    var sharedContext = {
        initData : 'started'
    }
    
    var responseObjects = {
         ok : function ok(data){
            console.log('ok', data);
            done()
        }
    }
    
    // timeout only happens if next or response is not called within time
    // final only gets called if
    //      a. Timeout
    //      b. next is called till no more middleware
    // continueOnTimeout (default false) if true calls next on timeout
    //
    var pipeline = Runner({
        timeout : 1000,
        continueOnTimeout : false
    }, allMiddleware)
    
    pipeline(sharedContext,
     responseObjects,
      function final(context){
        console.log('context', context);
    });
    
    
#Directory Loader

    var load = require('refab').LoadDirModules;
    // Assuming a Directory Structure like
    //
    // folder
    //     |___ module1
    //     |___ module2
    //     |___ module3
    //
    var myModules = load('folder', true)// second parameter is whether to reload on watch event
    
    console.log('', myModules);
    
    //Will output
    {
        module1 : [Function],
        module2 : [Function],
        module3 : [Function]
    }

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