helper-service

Generic utilities to assist in creating a helper service

Helper Service


Generic utilities to assist in creating a helper service

NPM

  • Use: require('helper-service')
  • Install: npm install --save helper-service
// Export our created and listening connect server with out special middleware 
module.exports = require('helper-service').start({
    port: null, /* optional */
    hostname: null, /* optional */
    logger: null, /* optional */
    middlewarefunction (reqres) {
        req.logger.log('info', 'hello', 'world')
        // ^ logs the arguments hello world with the log level info 
 
        req.sendResponse(
            {hello:'world'},
            200 /* optional */
        )
        // ^ sends 200 {hello:'world'} 
 
        req.sendError(
            new Error('something went wrong'),
            {hello:'world'} /* optional */,
            400 /* optional */
        )
        // ^ sends 400 {success:false, error:'something went wrong', hello:'world'} 
 
        req.sendSuccess(
            {hello:'world'} /* optional */,
            200 /* optional */
        )
        // ^ sends 200 {success:true, hello:'world'} 
    },
    nextfunction (errappserver) { /* optional */
        console.error(err)
    }
})

See the DocPad Helper Service for a production use case.

Discover the change history by heading on over to the HISTORY.md file.

Discover how you can contribute by heading on over to the CONTRIBUTING.md file.

These amazing people are maintaining this project:

  • Benjamin Lupton b@lupton.cc (https://github.com/balupton)

No sponsors yet! Will you be the first?

These amazing people have contributed code to this project:

Become a contributor!

Unless stated otherwise all works are:

  • Copyright © 2014+ Bevry Pty Ltd us@bevry.me (http://bevry.me)

and licensed under: