{"name":"listhen","version":"1.0.2","license":"MIT","_id":"listhen@1.0.2","maintainers":[{"name":"pi0","email":"pyapar@gmail.com"}],"homepage":"https://github.com/unjs/listhen#readme","bugs":{"url":"https://github.com/unjs/listhen/issues"},"dist":{"shasum":"3332af0cf77dd914e12d125c70a9c6aed9537033","tarball":"http://registry-npm.ywwl.com/listhen/download/listhen-1.0.2.tgz","fileCount":10,"integrity":"sha512-yXz0NIYfVJDBQK2vlCpD/OjSzYkur2mR44boUtlg0eES4holn7oYZf439y5JxP55EOzFtClZ8eZlMJ8a++FwlQ==","signatures":[{"sig":"MEQCIErkCKqzE/Gsu6TOaNJgBgfYpWSSApeW8iwtKP89zxDPAiAcqRgy4R/1rkaLntAR0p+wnxoqkZ3TvoGv42VebbiiBg==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}],"unpackedSize":93027,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJj0RoCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrpPg/+Ne072hyLPEoyi2p/W7StFfjOTa+BiVLODBKc5TUdR8ZIX1B5\r\n387bv+PdlJ3imTzZNzexP6zac1u9FXJn80+bBf4A/4W7BgKooOT7gbz/ArNQ\r\n+IrqNnlvMkWfuMAyH/9HHrmVdEfIuBNNFhdamhmEgjVKXtb/ayDp8lrqASml\r\nd6JUBLgDkyVyhzG8JeXf7kIgB5ir2SRg+RV4uIjy1IULLCX9TB8KJxd/PBOm\r\nuk7JaFY7JkihQJJrPEwdD4zXixHzr7f+nwlyVGH8qQkliGg3kwP++lCF0eqS\r\n5+e9GIUdLOJiFgTh/YLXsU5DE6JUayJ12lmfZ9wkIBzQNphGg3qtB3RJnS4H\r\nciJMXkzyyLp2U3+4nSWCeLCk7ZpRPSHYEI8u61r2QszPkZuXGczv4lUDsAf7\r\n2DdqrInOA3RMyYqvQwLrBE0pbt6YYtNwSVw5r5QyC3oo1Nkc5Q1tGbz9l+8I\r\n/U+1n2QQaPvpma0q+5mvL543LnjhiddPAc/gYlDVFIDZwlc94t7CFLfuQW76\r\n+0TutwpJjKKiXphNCe6n3wCg+bmqcF/nPPvEgVe9KW13hLdB8TckUsnaABWr\r\nccE93mUJJnHTojc+pL8kA24f1vRJADuJYbyPYZObDwomfoMh1vqBjuCEZ+jc\r\n7XoyL5q1qF1efRvtGRbiyPJBbaXWvwUIlGA=\r\n=VYb6\r\n-----END PGP SIGNATURE-----\r\n","size":26694,"noattachment":false,"key":"/listhen/-/listhen-1.0.2.tgz"},"main":"./dist/index.mjs","_from":"file:listhen-1.0.2.tgz","types":"./dist/index.d.ts","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"}},"scripts":{"dev":"vitest","lint":"eslint --ext .ts . && prettier -c src test","play":"jiti test/fixture/app","test":"pnpm lint && vitest run --coverage","build":"unbuild","release":"pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags"},"_npmUser":{"name":"pi0","email":"pyapar@gmail.com"},"_resolved":"/private/var/folders/s0/k4lcb4b50bj9r4fch4_1h_l40000gn/T/55d5706db2cd33537e77ce641f450076/listhen-1.0.2.tgz","_integrity":"sha512-yXz0NIYfVJDBQK2vlCpD/OjSzYkur2mR44boUtlg0eES4holn7oYZf439y5JxP55EOzFtClZ8eZlMJ8a++FwlQ==","repository":{"url":"git+https://github.com/unjs/listhen.git","type":"git"},"_npmVersion":"8.15.0","description":"![listhen](https://user-images.githubusercontent.com/904724/101662837-46845280-3a4a-11eb-9e9a-d5399e8af753.png)","directories":{},"_nodeVersion":"16.17.0","dependencies":{"ufo":"^1.0.1","defu":"^6.1.2","ip-regex":"^5.0.0","colorette":"^2.0.19","clipboardy":"^3.0.0","node-forge":"^1.3.1","http-shutdown":"^1.2.2","get-port-please":"^3.0.1"},"_hasShrinkwrap":false,"packageManager":"pnpm@7.17.1","devDependencies":{"jiti":"^1.16.2","eslint":"^8.32.0","vitest":"^0.28.2","unbuild":"^1.1.1","prettier":"^2.8.3","typescript":"^4.9.4","@types/node":"^18.11.18","changelogen":"^0.4.1","@types/node-forge":"^1.3.1","eslint-config-unjs":"^0.1.0","@vitest/coverage-c8":"^0.28.2"},"_npmOperationalInternal":{"tmp":"tmp/listhen_1.0.2_1674648066222_0.4675525099377933","host":"s3://npm-registry-packages"},"readme":"# 👂 listhen\n\n<!-- automd:badges -->\n\n[![npm version](https://img.shields.io/npm/v/listhen)](https://npmjs.com/package/listhen)\n[![npm downloads](https://img.shields.io/npm/dm/listhen)](https://npm.chart.dev/listhen)\n\n<!-- /automd -->\n\nElegant HTTP listener!\n\n[👉 Online Playground](https://stackblitz.com/github/unjs/listhen/tree/main/playground?startScript=dev)\n\n## Features\n\n✅ Dev server with HMR, static, WebSockets and TypeScript support with <a href=\"https://github.com/unjs/jiti\">unjs/jiti</a><br>\n\n✅ Works with Node.js, Express, and <a href=\"https://github.com/unjs/h3\">unjs/h3</a> out of the box <br>\n\n✅ Show the QR code of the public URL with <a href=\"https://github.com/unjs/uqr\">unjs/uqr</a><br>\n\n✅ Tunnel your local server to the world with <a href=\"https://github.com/unjs/untun\">unjs/untun</a><br>\n\n✅ Assign a port or fallback to a nicer alternative with <a href=\"https://github.com/unjs/get-port-please\">unjs/get-port-please</a>\n\n✅ Gracefully shutdown Server with <a href=\"https://github.com/thedillonb/http-shutdown\">http-shutdown</a><br>\n\n✅ Zero Config WebSockets with <a href=\"https://github.com/unjs/crossws\">unjs/crossws</a>\n\n✅ Copy the URL to the clipboard<br>\n\n✅ HTTPS support with self-signed certificates<br>\n\n✅ Open URL in browser<br>\n\n✅ Detect test and production environments to auto-adjust behavior<br>\n\n✅ Close on the exit signal<br>\n\n<div align=\"center\">\n<img width=\"100%\" src=\"./.assets/screenshot.png\">\n</div>\n\n## Quick Usage (CLI)\n\nYou can run your applications in localhost with TypeScript support and watch mode using `listhen` CLI:\n\nCreate `index.ts`:\n\n```ts\nexport default (req, res) => {\n  res.end(\"Hello World!\");\n};\n```\n\nor using [unjs/h3](https://github.com/unjs/h3):\n\n```ts\nimport { createApp, eventHandler } from \"h3\";\n\nexport const app = createApp();\n\napp.use(\n  \"/\",\n  eventHandler(() => \"Hello world!\"),\n);\n```\n\nor use npx to invoke `listhen` command:\n\n```sh\nnpx listhen -w ./index.ts\n```\n\n## Usage (API)\n\nInstall package:\n\n```bash\n# pnpm\npnpm i listhen\n\n# npm\nnpm i listhen\n\n# yarn\nyarn add listhen\n\n```\n\nImport into your Node.js project:\n\n```js\n// CommonJS\nconst { listen, listenAndWatch } = require(\"listhen\");\n\n// ESM\nimport { listen, listenAndWatch } from \"listhen\";\n```\n\n```ts\nconst handler = (req, res) => {\n  res.end(\"Hi!\");\n};\n\n// listener: { url, getURL, server, close, ... }\nconst listener = await listen(handler, options);\n```\n\n## Options\n\n### `port`\n\n- Default: `process.env.PORT` or 3000 or memorized random (see [get-port-please](https://github.com/unjs/get-port-please))\n\nPort to listen.\n\n### `hostname`\n\n- Default: `process.env.HOST || '0.0.0.0'`\n\nDefault hostname to listen.\n\n### `https`\n\n- Type: Boolean | Object\n- Default: `false`\n\nListen on HTTPS with SSL enabled.\n\n#### Self-Signed Certificate\n\nBy setting `https: true`, listhen will use an auto-generated self-signed certificate.\n\nYou can set https to an object for custom options. Possible options:\n\n- `domains`: (Array) Default is `['localhost', '127.0.0.1', '::1']`.\n- `validityDays`: (Number) Default is `1`.\n\n#### User-Provided Certificate\n\nSet `https: { cert, key }` where the cert and key are paths to the SSL certificates.\nWith an encrypted private key, you also need to set `passphrase` on the `https` object.\n\nTo provide a certificate stored in a keystore set `https: { pfx }` with a path to the keystore.\nWhen the keystore is password protected also set `passphrase`.\n\nYou can also provide an inline cert and key instead of reading from the filesystem. In this case, they should start with `--`.\n\n### `showURL`\n\n- Default: `true` (force disabled on a test environment)\n\nShow a CLI message for the listening URL.\n\n### `baseURL`\n\n- Default: `/`\n\n### `open`\n\n- Default: `false` (force disabled on test and production environments)\n\nOpen the URL in the browser. Silently ignores errors.\n\n### `clipboard`\n\n- Default: `false` (force disabled on test and production environments)\n\nCopy the URL to the clipboard. Silently ignores errors.\n\n### `isTest`\n\n- Default: `process.env.NODE_ENV === 'test'`\n\nDetect if running in a test environment to disable some features.\n\n### `autoClose`\n\n- Default: `true`\n\nAutomatically close when an `exit` event, `SIGTERM`, `SIGINT` or `SIGHUP` signal is received in the process.\n\n### `publicURL`\n\n- Default: (the first public URL listening)\n\nThe public URL to show in the CLI output\n\n### `extraURLs`\n\n- Type: `Array<{ title: string, url?: string, env?: string }>`\n\nExtra URLs to show in the CLI output. Use `url` for a static link or `env` to resolve the URL from an environment variable at `showURL()` time.\n\nBy default, `[{ title: \"Portless\", env: \"PORTLESS_URL\" }]` is used to surface a Portless URL when present. Pass `extraURLs: []` to disable.\n\n### `qr`\n\n- Default: `true`\n\nPrint QR Code for public address.\n\n### `public`\n\n- Default: `false` for development or when `hostname` is `localhost` and `true` for production\n\nWhen enabled, listhen tries to listen to all network interfaces. You can also enable this option using `--host` CLI flag.\n\n### `ws`\n\n- Default: `false`\n\nEnable experimental WebSocket support using [unjs/crossws](https://crossws.unjs.io/) or node upgrade handler.\n\nOption can be a function for Node.js `upgrade` handler (`(req, head) => void`) or an Object to use [CrossWS Hooks](https://crossws.unjs.io/guide/api).\n\nWhen using dev server CLI, you can easily use `--ws` and a named export called `websocket` to define [CrossWS Hooks](https://github.com/unjs/crossws) with HMR support!\n\n## License\n\n<!-- automd:contributors license=MIT author=\"pi0\" -->\n\nPublished under the [MIT](https://github.com/unjs/listhen/blob/main/LICENSE) license.\nMade by [@pi0](https://github.com/pi0) and [community](https://github.com/unjs/listhen/graphs/contributors) 💛\n<br><br>\n<a href=\"https://github.com/unjs/listhen/graphs/contributors\">\n<img src=\"https://contrib.rocks/image?repo=unjs/listhen\" />\n</a>\n\n<!-- /automd -->\n\n<!-- automd:with-automd -->\n\n---\n\n_🤖 auto updated with [automd](https://automd.unjs.io)_\n\n<!-- /automd -->\n","publish_time":1674648066390,"_cnpm_publish_time":1674648066390,"dist-tags":{"latest":"1.10.1"}}