Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
test
README.md
index.js
package.json

README.md

node-engine-light

be compatible with Engine Light

installation

$ npm install engine-light

documentation

Require engine-light and create an object

var EngineLight = require('engine-light')

var engineLight = new EngineLight()

Then use it right away to generate Engine Light compliant responses

engineLight.getStatus()
// returns a Promise of '{"status":"ok","updated":1402120470799,"dependencies":[],"resources":{}}'

engineLight.getStatus('doing aiight')
// returns a Promise of '{"status":"doing aiight","updated":1402120470799,"dependencies":[],"resources":{}}'

You can add your own depdencies with the addDependency function

engineLight.addDependency('Postgres')
engineLight.getStatus()
// returns a Promise of '{"status":"ok","updated":1402120706100,"dependencies":["Postgres"],"resources":{}}'

You can add resources as well. addResource takes two parameters:

The first is expected to be a string, and the name of the resource

The second (optional) is expected to be a function, that returns the current resource usage information as a percentage of the allowed limit.

function getSendgridUsage() {
	var allowed, used
	percentage = (allowed/used) * 100

	return percentage
}

engineLight.addResource('Sendgrid', getSendgridUsage)
engineLight.getStatus()
// returns a Promise of '{"status":"ok","updated":1402121246418,"dependencies":[],"resources":{"Sendgrid":17.85}}'

Engine Light can also be be used as middleware.

var express = require('express')
var app = express()
var EngineLight = require('engine-light')

var engineLight = new EngineLight()
app.use(engineLight.getMiddleware())

app.listen(80)

contributors

@jeremiak @jden

Please submit pull requests and issues through github.

You can run tests with npm test