hea

headrush

A minimal solution to defer application start after resolving your network & processing dependencies.

Showing:

Popularity

Downloads/wk

20

GitHub Stars

3

Maintenance

Last Commit

4yrs ago

Contributors

3

Package

Dependencies

0

Size (min+gzip)

0.6KB

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

Headrush  Build Status    Coverage Status

A minimal solution to defer application starts after you have resolved your network or file dependencies.

If you have multiple dependencies like connecting to a database or other initial processing that needs to be done before the application starts, this will come in handy.


Installation

  npm install headrush

Usage

You need to provide the initial dependencies you're expecting , after which the ready event will be emitted. This needs to be provided once only. Also, you need to call the stun function once you have finished some specific processing.

Single file example

var HeadRush = require('headrush')
var headRush = new HeadRush({
    deps: [
    'intialProcessing',
    'redis',
    'mongo'
]})


headRush.on('ready', function() {
    // call the function to start your app
    console.log('ready')
})

function initialProcessing() {
    // do some processing here
    headRush.stun({
        dep: 'intialProcessing'
    })
}

function connectToRedis() {
    // After connecting to redis
    headRush.stun({
        dep: 'redis'
    })
}

function connectToMongo() {
    // After connecting to mongo
    headRush.stun({
        dep: 'mongo'
    })
}

initialProcessing()
connectToMongo()
connectToRedis()

Multiple file Example

File 1

    var HeadRush = require('headrush')
    var headRush = new HeadRush({
        deps: [
        'intialProcessing',
        'someMoreProcessing'
    ]})

    function initialProcessing() {
        // do some processing here
        headRush.stun({
            dep: 'intialProcessing'
        })
    }

File 2

    var HeadRush = require('headrush')
    var headRush = new HeadRush()

    function someMoreProcessing() {
        // do some processing here
        headRush.stun({
            dep: 'someMoreProcessing'
        })
    }


License

MIT

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100