{"name":"boot-in-the-arse","version":"0.1.0","description":"Asynchronous bootstrapping of Node applications","main":"boot.js","scripts":{"test":"standard && tap test/*.js"},"precommit":"test","repository":{"type":"git","url":"git+https://github.com/mcollina/boot-in-the-arse.git"},"keywords":["async","boot","delayed","open"],"author":{"name":"Matteo Collina","email":"hello@matteocollina.com"},"license":"MIT","bugs":{"url":"https://github.com/mcollina/boot-in-the-arse/issues"},"homepage":"https://github.com/mcollina/boot-in-the-arse#readme","devDependencies":{"pre-commit":"^1.1.3","standard":"^7.1.2","tap":"^6.3.0"},"dependencies":{"fastq":"^1.4.1"},"gitHead":"44fc1fb1aad9b8720e6869002e351babb277385c","_id":"boot-in-the-arse@0.1.0","_shasum":"41f03e38e3768a4d963a0744c0342fefad9dd23f","_from":".","_npmVersion":"3.10.5","_nodeVersion":"4.4.5","_npmUser":{"name":"matteo.collina","email":"hello@matteocollina.com"},"dist":{"shasum":"41f03e38e3768a4d963a0744c0342fefad9dd23f","tarball":"http://registry-npm.ywwl.com/boot-in-the-arse/download/boot-in-the-arse-0.1.0.tgz","integrity":"sha512-WEn3pqszKoLviNaK1A/lNykxYGBQ+gjFpct+c6A+sQ11QIuCDbKVu6KRCtSA6FFMJoTdERCcqnOBBMeBFtqX8A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIGM/PwWlIPJEEicSaW/hDs2kYDhBY53GSQMOkYVXNZm4AiAKfGYC1b7T89O/Lt/0nbxufuFfwEtcIV43ulxcGSsBbw=="}],"size":4292,"noattachment":false,"key":"/boot-in-the-arse/-/boot-in-the-arse-0.1.0.tgz"},"maintainers":[{"name":"matteo.collina","email":"hello@matteocollina.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/boot-in-the-arse-0.1.0.tgz_1471330911370_0.9502336592413485"},"directories":{},"readme":"# boot-in-the-arse &nbsp;&nbsp;[![Build Status](https://travis-ci.org/mcollina/boot-in-the-arse.svg)](https://travis-ci.org/mcollina/boot-in-the-arse)\n\nAsynchronous bootstrapping made easy. Wait for all components/plugins to start, and then start your whole app.\n\n`boot-in-the-arse` is fully reentrant and graph-based. You can load\ncomponents/plugins _within_ plugins, and be still sure that things will\nhappen in the right order.\n\n[![JavaScript Style Guide](https://cdn.rawgit.com/feross/standard/master/badge.svg)](https://github.com/feross/standard)\n\n* [Install](#install)\n* [Example](#example)\n* [API](#api)\n* [Acknowledgements](#acknowledgements)\n* [License](#license)\n\n<a name=\"install\"></a>\n## Install\n\nTo install `boot-in-the-arse`, simply use npm:\n\n```\nnpm install boot-in-the-arse --save\n```\n\n<a name=\"example\"></a>\n## Example\n\nThe example below can be found [here][example] and ran using `node example.js`. It\ndemonstrates how to use `boot-in-the-arse` to load functions /\nplugins in\norder.\n\n\n```js\n'use strict'\n\nconst boot = require('boot-in-the-arse')()\n\nboot\n  .use(first, { hello: 'world' })\n  .after((cb) => {\n    console.log('after first and second')\n    cb()\n  })\n  .use(third, (err) => {\n    if (err) {\n      console.log('something bad happened')\n      console.log(err)\n    }\n\n    console.log('third plugin loaded')\n  })\n  .ready(function () {\n    console.log('application booted!')\n  })\n\nfunction first (instance, opts, cb) {\n  console.log('first loaded', opts)\n  instance.use(second, cb)\n}\n\nfunction second (instance, opts, cb) {\n  console.log('second loaded')\n  process.nextTick(cb)\n}\n\nfunction third (instance, opts, cb) {\n  console.log('third loaded')\n  cb()\n}\n```\n\n<a name=\"api\"></a>\n## API\n\n  * <a href=\"#constructor\"><code><b>boot()</b></code></a>\n  * <a href=\"#use\"><code>instance.<b>use()</b></code></a>\n  * <a href=\"#after\"><code>instance.<b>after()</b></code></a>\n  * <a href=\"#ready\"><code>instance.<b>ready()</b></code></a>\n  * <a href=\"#express\"><code>boot.<b>express()</b></code></a>\n\n-------------------------------------------------------\n<a name=\"constructor\"></a>\n\n### boot([instance], [started])\n\nStart a booting sequence.\n\n`instance` will be used as the first\nargument of all plugins loaded and `use`, `after` and `ready` \nfunction will be\nadded to that object, keeping the support for the chainable API:\n\n```js\nconst server = {}\n\nrequire('boot-in-the-arse')(server)\n\nserver.use(function first (s, opts, cb) {\n  // s is the same of server\n  s.use(function second (s, opts, cb) {\n    cb()\n  }, cb)\n}).after(function (cb) {\n  // after first and second are finished\n  cb()\n})\n```\n\nOptions:\n\n* `expose`: a key/value property to change how `use`, `after` and `ready` are exposed.\n\nEvents:\n\n* `'error'`  if something bad happens\n* `'start'`  when the application starts\n\nThe `boot` function can be used also as a\nconstructor to inherits from.\n\n-------------------------------------------------------\n<a name=\"use\"></a>\n\n### app.use(func, [opts], [cb])\n\nLoads a functions asynchronously. The function must have the\nsignature:\n\n```js\nfunction plugin (server, opts, done) {\n  done()\n}\n```\n`done` must be called only once.\n\nReturns the instance on which `use` is called, to support a\nchainable API.\n\nIf you need to add more than a function and you don't need to use a different options object or callback, you can pass an array of functions to `.use`.\n```js\nboot.use([first, second, third], opts, cb)\n```\nThe functions will be loaded in the same order as they are inside the array.\n\n-------------------------------------------------------\n<a name=\"after\"></a>\n\n### app.after(func([done]), [cb])\n\nCalls a functon after all the previously defined plugins are loaded, including\nall their dependencies. The `'start'` event is not emitted yet.\n\n```js\nboot.after(function (done) {\n  done()\n})\n```\n\n`done` must be called only once.\n\nReturns the instance on which `after` is called, to support a\nchainable API.\n\n-------------------------------------------------------\n<a name=\"ready\"></a>\n\n### app.ready(func([done]))\n\nCalls a functon after all the plugins and `after` call are\ncompleted, but befer `'start'` is emitted. `ready` callbacks are\nexecuted one at a time.\n\n```js\nboot.ready(function (done) {\n  done()\n})\n```\n\n`done` must be called only once.\n\nReturns the instance on which `ready` is called, to support a\nchainable API.\n\n-------------------------------------------------------\n<a name=\"express\"></a>\n\n### boot.express(app)\n\nSame as:\n\n```js\nconst app = express()\n\nboot(app, {\n  expose: {\n    use: 'load'\n  }\n})\n```\n\n-------------------------------------------------------\n\n## Acknowledgements\n\nThis project was kindly sponsored by [nearForm](http://nearform.com).\n\n## License\n\nCopyright Matteo Collina 2016, Licensed under [MIT][].\n\n[MIT]: ./LICENSE\n[example]: ./example.js\n","publish_time":1471330912970,"_cnpm_publish_time":1471330912970,"dist-tags":{"latest":"0.3.0"}}