middleware-resolver

2.0.0 • Public • Published

middleware-resolver

Dependency (and semi-event) based middleware running.

Task format

A tasks/jobs list is an array containing task descriptors:

property description
requires Jobs required to be finished before this one can run.
optional Jobs that, if present, should be run before this one.
before Jobs that, if present, will only run after this job completes (reverse dependency)
notif Don't run if task is completed. Implies optional dependency
priority Priority hint. Higher means closer to the outter/first run middleware.
task function (done, next) to execute. In the function body next("result_name");

For example:

[
    {
        name: "task7",
        requires: [ "task6" ],
        optional: "task1",
	priority: 10,
        task: function (done, next) {
            // more code

            /*  Emit the task name and, optionally, any auxiliary event /
                dependency that is satisfied. The done function can be used as
                many times as practical, or not at all (eg. a case of failure).
             */
            done("task7");

            // more code
            next(); // Run the next task
            // more code
        }
    }
]

Examples

Take a look at test.js in the repository for a simple example.

Notes & license

This project is available on GitHub and npm.

The project is licensed as LGPLv3, the license file is included in the project directory.

Copyright 2015 Stefan Hamminga - prjct.net

Package Sidebar

Install

npm i middleware-resolver

Weekly Downloads

2

Version

2.0.0

License

LGPL-3.0

Last publish

Collaborators

  • stefanhamminga