{"_id":"@constgen/neutrino-koa-launcher","_rev":"2-356f871d17b780d3d846108101717f0e","name":"@constgen/neutrino-koa-launcher","dist-tags":{"latest":"1.9.2"},"versions":{"1.6.0":{"name":"@constgen/neutrino-koa-launcher","version":"1.6.0","description":"Neutrino middleware for an automatic Koa application launching in a server with hot reload","main":"index.js","author":{"name":"Constantine Genchevsky","email":"const.gen@gmail.com"},"license":"GPL-3.0","repository":{"type":"git","url":"git+https://github.com/constgen/constgen-neutrino.git"},"homepage":"https://github.com/constgen/constgen-neutrino/packages/koa-launcher","keywords":["neutrino","neutrino-middlware","middlware","preset","webpack","koa","hot"],"dependencies":{"chalk":"~4.1.0","selfsigned":"~1.10.7","del":"~5.1.0","deepmerge":"~4.2.2"},"peerDependencies":{"neutrino":"^9.0.0","webpack":"^4.0.0","koa":"^2.3.0"},"engines":{"node":">=10","npm":">=5.4.0"},"bugs":{"url":"https://github.com/constgen/constgen-neutrino/issues"},"_id":"@constgen/neutrino-koa-launcher@1.6.0","_nodeVersion":"12.18.3","_npmVersion":"6.14.6","dist":{"integrity":"sha512-0oiZLr4NpYe4cIUQGdzULKKuNXXFu9wQ/H8BbwZTKQyTk2uoMfpMgJmcmhgWYtMMCtrmlXYY6u/sS9XUr8VrwA==","shasum":"91afd3da4a1564fb6c4efbfae0a8b01afcc6a5ec","tarball":"https://registry.npmjs.org/@constgen/neutrino-koa-launcher/-/neutrino-koa-launcher-1.6.0.tgz","fileCount":9,"unpackedSize":51649,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfPSIqCRA9TVsSAnZWagAAOnwP/3sDscpFJg8Fk+MMebnH\nmURLGbF2ns2FK7CuP1motwlDtaN54wNRlYZuQDk+PaYlvNQmd3KpONWc3GUo\nj038asWr8qlYVs9g5xRU545VMu7B1jUXtDB7FOoVYDDb1p/esGWduGU/Zc5e\n2eOBfGYT8J/1rGpnovbtKyfZ0IwgAfu57SA/L1L+6FUpckRG8s93QdSilKKy\nY8+2SY9EYe0eUNrw1lysZwtRdBg0cMwGSUpAqoq16GcUf3d381vwagBnQCvc\nmXWdjUCqrbL6tMhM/NmhBbUle2m97/ss7Iv0UsbVqVqul0g9hNpfvpf1QlZi\npUl8ADuc4C4fFkqjTOxSc18/bwjc42VVPUJ86jDjQyqBXn7jye7hXD83aj/E\nNT3hLfgPPH0Ibl612jy2Wn7curktjTxXFDuyYnMOBRAXe9LZym/+NAE/7BKz\n2YIJW93cwMUwXW2ncFm1t2BMZwePjud283dUnW94XtVrwkEwmj3vzHIOSjLm\nhQccJM4r1uS927KPyN0F82agRILT6prvJ12T7TTP4X6Vc+9vVUwlKVohXU8J\neuLT2+dji22mUG9uibqjjaQ/A9cGLZ25ndfPcrP8kLu4CzercMvkLkOxK7Fg\n0inhCK5tRsvDpqhrwjemY01Zf9yudxKjS/nsXHLP7dxEDdRf+qEFxNtSp4T+\n9n6L\r\n=qN+O\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQD4be8OREj0iu+pSTmOAsH8Rtr1bgzlfxquGkJ5RWZh2AIgRPhhpB8CISKGuGlyAWcegcP0P1/+hnzIBFXGlXQrrh8="}]},"maintainers":[{"name":"constgen","email":"const.gen@gmail.com"}],"_npmUser":{"name":"constgen","email":"const.gen@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/neutrino-koa-launcher_1.6.0_1597841962342_0.10166109838248905"},"_hasShrinkwrap":false},"1.9.2":{"name":"@constgen/neutrino-koa-launcher","version":"1.9.2","description":"Neutrino middleware for an automatic Koa application launching in a server with hot reload","main":"index.js","author":{"name":"Constantine Genchevsky","email":"const.gen@gmail.com"},"license":"GPL-3.0","repository":{"type":"git","url":"git+https://github.com/constgen/constgen-neutrino.git"},"homepage":"https://github.com/constgen/constgen-neutrino/tree/master/packages/koa-launcher","keywords":["neutrino","neutrino-middleware","middleware","preset","webpack","koa","hot"],"dependencies":{"chalk":"~4.1.0","selfsigned":"~1.10.7","del":"~5.1.0","deepmerge":"~4.2.2"},"peerDependencies":{"neutrino":"^9.0.0","webpack":"^4.0.0","koa":"^2.3.0"},"engines":{"node":">=10","npm":">=5.4.0"},"bugs":{"url":"https://github.com/constgen/constgen-neutrino/issues"},"_id":"@constgen/neutrino-koa-launcher@1.9.2","_nodeVersion":"12.18.4","_npmVersion":"6.14.6","dist":{"integrity":"sha512-QB/Vx4NGafLiYwzrOqfNK7cugfd5gP/pLXbBhCFkQcXCG3hMgcCNI7pDbnE5t1OsbII9FlXWS9ib9eyr4IdNyw==","shasum":"041ed3e8e0398fb72f41004ffc062777e480d0b7","tarball":"https://registry.npmjs.org/@constgen/neutrino-koa-launcher/-/neutrino-koa-launcher-1.9.2.tgz","fileCount":9,"unpackedSize":51663,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJfcmxSCRA9TVsSAnZWagAAsJ0P/3Yg6TY5oF7HL2gHpAM9\nNJMZwEDgCC8xfzmqnci631tBZdIDLcPrseOb4CwhLqLeTSgv3eOeTI9m4Ce5\nGEsOwkSeaYNufJFn4VeIL+mzjqEHw51nh2EFmSqDJti0gv7w4+QmMv/TL9Sk\nMYmJmwNYH5cNV52FKLJin+0ORi51sZeTBb4Pej++p8fUCmnI/Ckg4xMbot5N\nDJ/cW8V32I46y3YCjA0obXIdsPKvuN47SmiYHWIH0but8mrCQu98O0+lWGKl\nhphyCgYqdkWmucjZNx0qwCVzeUEYay32FHYDM4fenuoQiLShNowMBIg0NLmq\nSDdt2iLD6nXMlSWlhliP8px4O215qLwHD5fxdCJRjXeEatcPy7i/J2AunDLH\nguDepsrJZtF5yuwGBP9j/SUAyA2gDm4YMc8A1NU0Fd7P31Iofm66AAmRwyWY\n08S5ewh62BaAQRSNfXXUZSQsxuHV9xZmabuOvRDQ0gxkr/xz2+O1Ncy5nqYi\nqEg//W8EaHADg8zkt3l01KHjdCw6aYMplDwcn5gorPDNhRW4MdIfwzYBkWkt\nFhTP1ozmtjrqhGwAhydhS3gfywQneflYLsYd+HfyvnMVj3M67JKaWOZIzP6S\nBbUN1KK+ZfprZz+WIkCxZufeUzDA5w/wenD5DtSYNh17dGUe8BIdsPqlrkPz\niyV3\r\n=T4cI\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIARvNyaLIIW1BpvzvflcEDgOmOjSDTY8tZE6IX04nYTBAiBXfClMgQ2SP5D4KjtCBTc9j3orNbg/70nEB2T2odyTyQ=="}]},"maintainers":[{"name":"constgen","email":"const.gen@gmail.com"}],"_npmUser":{"name":"constgen","email":"const.gen@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/neutrino-koa-launcher_1.9.2_1601334353758_0.8228161775165281"},"_hasShrinkwrap":false}},"time":{"created":"2020-08-19T12:59:22.299Z","1.6.0":"2020-08-19T12:59:22.469Z","modified":"2022-04-05T00:59:56.521Z","1.9.2":"2020-09-28T23:05:54.015Z"},"maintainers":[{"name":"constgen","email":"const.gen@gmail.com"}],"description":"Neutrino middleware for an automatic Koa application launching in a server with hot reload","homepage":"https://github.com/constgen/constgen-neutrino/tree/master/packages/koa-launcher","keywords":["neutrino","neutrino-middleware","middleware","preset","webpack","koa","hot"],"repository":{"type":"git","url":"git+https://github.com/constgen/constgen-neutrino.git"},"author":{"name":"Constantine Genchevsky","email":"const.gen@gmail.com"},"bugs":{"url":"https://github.com/constgen/constgen-neutrino/issues"},"license":"GPL-3.0","readme":"# @constgen/neutrino-koa-launcher\n\n[![npm](https://img.shields.io/npm/v/@constgen/neutrino-koa-launcher.svg)](https://www.npmjs.com/package/@constgen/neutrino-koa-launcher)\n[![npm](https://img.shields.io/npm/dt/@constgen/neutrino-koa-launcher.svg)](https://www.npmjs.com/package/@constgen/neutrino-koa-launcher)\n\n[Neutrino](https://neutrino.js.org) middleware for an automatic Koa application launching in a server with hot reload\n\nUsing this middleware your entry point should only export the Koa instance process. The server will be created automatically and will wrap your application.\n\n**src/index.js**\n\n```js\nlet Koa = require('koa')\n\nmodule.exports = new Koa()\n   .use(function ({ request, response }) {\n      response.body = { success: true }\n   })\n```\n\nYou should not have to call `new Koa().listen()`\n\n## Features\n\n- Built-in HTTP server for launching the application on development and production\n- Hot Module Replacement with source-watching during development\n- Disabled redundant `[HMR]` console messages\n- You can change your files without restarting the server\n- Debug console cleared on every file change. Your outdated logs will be removed\n- Automatically discovers free HTTP port to run a server locally\n- Graceful server shutdown\n- Outputs building log to `stdout` and `stderr`. No pollution to the console\n- Shows PID (Process ID) in the output\n- **Only Linux and MacOS:** Sets the NodeJS process name the same as the project name. So can be easily found with `ps x | grep myname`\n\n## Requirements\n\n- Node.js v10+\n- Neutrino v9\n- Webpack v4\n- Koa v2.3+\n\n## Installation\n\n`@constgen/neutrino-koa-launcher` can be installed from NPM. You should install it to `\"dependencies\"` (--save) or `\"devDependncies\"` (--save-dev) depending on your goal.\n\n```bash\nnpm install --save @constgen/neutrino-koa-launcher\n```\n\n## Usage\n\n### In preset\n\nRequire this package and plug it into Neutrino. The following shows how you can pass an options object to the middleware, showing the **defaults**:\n\n```js\nlet koaLauncher = require('@constgen/neutrino-koa-launcher')\n\nneutrino.use(koaLauncher({\n   port: undefined, // Set default port\n   http: 1, // Set HTTP version\n   ssl : undefined // Set SSL certificates\n}))\n```\n\n### In **neutrinorc**\n\nThe middleware also may be used together with another presets in Neutrino rc-file, e.g.:\n\n**.neutrinorc.js**\n\n```js\nlet koaLauncher = require('@constgen/neutrino-koa-launcher')\n\nmodule.exports = {\n   use: [\n      koaLauncher()\n   ]\n}\n```\n\n## Customizing\n\n### Port\n\nThere are multiple ways to customize the HTTP port of your application server.\n\nYou can configure a **default** port of the server in options using `server.port` property in the middleware options. For example:\n\n```js\nkoaLauncher({\n   port: 8080\n})\n```\n\nNow your server will start on `8080` in both production and development modes. But this port value is considered a **default** value and may be overridden any time by `PORT` environment variable. This may be useful for production environments as the server will check `process.env.PORT` in the runtime first and then fallback to a port you have defined.\n\nThe default behavior of port when not configured is to default to `80`/`443` on production and to take random free default port on development.\n\nYou can choose random free port on both production and development by passing one of these values: `false`, `null`, `0`. For example:\n\n```js\nkoaLauncher({\n   port: 0 // 0 | false | null\n})\n```\n\n`PORT` environment variable will always have a priority over any configuration.\n\n### Host\n\nBy default the server starts on a default IPv6/IPv4 host which exposes it to local network. There is no way to configure a server host from the middleware options. But you still can use `HOST` environment variable to define your custom host.\n\n### HTTP version\n\nThis middleware uses HTTP v1.x by default. You can switch to HTTP v2 in options.\n\n```js\nkoaLauncher({\n   http: 2 // default is 1\n})\n```\n\n### SSL\n\nYou can provide paths to own SSL certificate and a public key\n\n```js\nkoaLauncher({\n   ssl: {\n      cert: path.resolve(__dirname, './ssl/ssl.cert'),\n      key : path.resolve(__dirname, './ssl/ssl.key')\n   }\n})\n```\n\nA relative path to the project root also can be used\n\n```json\n{\n   cert: './ssl/ssl.cert',\n   key: './ssl/ssl.key'\n}\n```\n\nA temporary locally self-signed certificate can be configured by just passing `true`\n\n```js\nkoaLauncher({\n   ssl: true\n})\n```\n\n## Graceful Shutdown\n\n`@constgen/neutrino-koa-launcher` automatically shutdowns a server instance gracefully. Application server prints this message to signal successful closing when exited:\n\n```bash\nServer shutting down...\nServer closed\n```\n\nDuring shutdown these steps are performed\n\n1. Stop listening new requests\n2. Close all open inactive connections\n3. Wait current requests to end and close their connections at the end\n\nThe middleware doesn't forcefully exit a process but waits for queued operations to finish including your async Koa middlewares. In most cases you are **not required** to handle it explicitly. But if you have some long running operations or timers outside Koa middlewares that continue event loop then you should take care of them by yourself. Other will be handled by `@constgen/neutrino-koa-launcher`. The good practice is to use this in your code in cases of shutdown:\n\n```js\n['SIGINT', 'SIGTERM', 'SIGBREAK', 'SIGHUP'].forEach(function (signal) {\n   process.once(signal, function () {\n      // abort all async operations\n      // ...\n      // cancel all timers\n      // ...\n      process.exitCode = 0\n   })\n})\n```\n\nDon't call `process.exit()` as it considered a bad practice. The application should exit naturally when there is an empty call stack and no more scheduled tasks. You should see this at the very end if the finishing of the application is correct:\n\n```bash\nApplication exited\n```\n\nIn case your application will not finish for some reason in 10 seconds, there is a timeout that kills the application forcefully. You will not be able to handle this termination. The application will exit with an error signal right after this message\n\n```bash\nServer killed, due to timeout\n```","readmeFilename":"README.md"}