1.1.1 • Published 6 years ago

@rill/chain v1.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
6 years ago

This module is used internally by Rill but is extracted for convenience. Composes all functions and Rill apps provided into a valid middleware function that returns a promise.

Installation

npm install @rill/chain

Example

import chain from "@rill/chain";

const stack = [];

// Regular functions that return anything
// but they will be resolved as promises.
stack.push((ctx, next)=> {
  return Promise.resolve(true);
})

// Async/await functions
stack.push(async (ctx, next)=> {
  await Promise.resolve(true);
});

// Other apps.
const app = new Rill();
app.use(...);
stack.push(app);

// Compose it into a function (returns a promise).
const fn = chain(stack)

// Call the function with a context.
fn({}).catch((err)=> {
  console.error(err.stack);
  process.exit(1);
});

Contributions

  • Use npm test to run tests.

Please feel free to create a PR!

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

7 years ago

1.0.6

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago

0.2.2

8 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.0

9 years ago