0.1.1 • Published 10 years ago

engine-light v0.1.1

Weekly downloads
3
License
ISC
Repository
github
Last release
10 years ago

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

0.1.1

10 years ago

0.1.0

10 years ago

0.0.3

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago