0.2.11 • Published 11 years ago

apprunner v0.2.11

Weekly downloads
113
License
-
Repository
github
Last release
11 years ago

App Runner

App Runner allows to to generate and maintain many apps using shared code. Require is great, App Runner is greater!

App Runner does three things:

  • Provides loadable apis
  • Manages application errors
  • Emails anomaly reports

Why App Runner? App Runner is App Lego.

If you make many Web apps and you have several of them for example accessing Facebook or using the same type of database, App Runner enables you to architect that in a repeatable pattern. App Runner allows you to use json to configure where code comes from and its settings.

Reference

App Runner handles process exceptions and SIGINT.

  • Exit code 0 is SIGINT
  • Exit code 2 is unhandled exception

initApp(defaults, app, cb)

  • defaults: options, typically loaded by haraldops

    • .init.appFolder: string: the folder of initial script
    • .init.logger: optional function(string): logging, default console.log
    • .init.ops.sendMail: optional function(subject, body): Sends mail, default none
    • .api: optional, indicates that Api Manager should be used
    • .api.apiMap: api configurations
  • app: Web server, has .on and .get methods

  • cb(err): optional function

getApi(opts, cb)

get an api implementation

  • opts: object
  • .api: string: name of api function to be loaded
  • cb(err, module)

APIs are either configured directly in opts, or in defaults provided at App Runner init

If module has module.emitter, APp Runner will listen and manage error events

anomaly(...)

Report any argument as an anomaly, to the log and if so configured a periodcal email.

enableAnomalyMail(flag)

control emailing on or off: flag: boolean, default: false

getCbCounter()

Ensures that all callbacks has completed

var haraldutil = require('haraldutil')
var cbc = haraldutil.getCbCounter()
setTimeout(cbc.add(callback), 100)
setTimeout(cbc.add(callback), 100)

function callback() {
  if (cbc.isDone(arguments.callee))
    console.log('All callbacks completed.')
  else console.log('Not done yet...')
}
Not done yet...
All callbacks completed.

var cbc = getCbCounter(opts)

  • opts: optional object
  • opts.emitter: optional event emitter or boolean. default: errors are thrown

    • false: errors are ignored
    • emitter: errors are emitted
  • opts.callback: function or array of function: add is done for each function

cbc: object

  • .add(f): adds a callback for function f, return value: f
  • .isDone(f): notes one callback completed. returns true if all callbacks complete, otherwise false
  • .getStatus(): gets an object representing the current state

Examples

TODO

Notes

(c) Harald Rudell wrote this for node in September, 2012

No warranty expressed or implied. Use at your own risk.

Please suggest better ways, new features, and possible difficulties on github

0.2.11

11 years ago

0.2.10

11 years ago

0.2.9

11 years ago

0.2.8

11 years ago

0.2.7

11 years ago

0.2.6

11 years ago

0.2.5

11 years ago

0.2.4

11 years ago

0.2.3

11 years ago

0.2.2

11 years ago

0.2.1

11 years ago

0.2.0

11 years ago

0.1.8

11 years ago

0.1.6

11 years ago

0.1.5

11 years ago

0.1.4

11 years ago

0.1.3

11 years ago

0.1.2

11 years ago

0.1.1

11 years ago

0.1.0

11 years ago

0.0.17

11 years ago

0.0.16

11 years ago

0.0.15

12 years ago

0.0.14

12 years ago

0.0.13

12 years ago

0.0.12

12 years ago

0.0.11

12 years ago

0.0.10

12 years ago

0.0.9

12 years ago

0.0.7

12 years ago

0.0.6

12 years ago

0.0.5

12 years ago

0.0.4

12 years ago

0.0.3

12 years ago

0.0.2

12 years ago

0.0.1

12 years ago

0.0.0

12 years ago