{"_id":"@vinxi/listhen","_rev":"1-05c6d70ce11f30a1143decf326887832","name":"@vinxi/listhen","dist-tags":{"latest":"1.5.6"},"versions":{"1.5.5":{"name":"@vinxi/listhen","version":"1.5.5","description":"👂 Elegant HTTP Listener","repository":{"type":"git","url":"git+https://github.com/unjs/listhen.git"},"license":"MIT","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./cli":{"types":"./dist/cli.d.ts","import":"./dist/cli.mjs","require":"./dist/cli.cjs"}},"main":"./dist/index.mjs","types":"./dist/index.d.ts","bin":{"listen":"bin/listhen.mjs","listhen":"bin/listhen.mjs"},"scripts":{"build":"unbuild","dev":"vitest","lint":"eslint --ext .ts . && prettier -c src test","lint:fix":"eslint --fix --ext .ts . && prettier -w src test","listhen":"node ./scripts/listhen.mjs","play":"node ./scripts/listhen.mjs -w ./playground","release":"pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags","test":"pnpm lint && vitest run --coverage"},"dependencies":{"@parcel/watcher":"^2.3.0","@parcel/watcher-wasm":"2.3.0","citty":"^0.1.4","clipboardy":"^3.0.0","consola":"^3.2.3","defu":"^6.1.2","get-port-please":"^3.1.1","h3":"^1.8.1","http-shutdown":"^1.2.2","jiti":"^1.20.0","mlly":"^1.4.2","node-forge":"^1.3.1","pathe":"^1.1.1","std-env":"^3.4.3","ufo":"^1.3.0","untun":"^0.1.2","uqr":"^0.1.2"},"devDependencies":{"@types/node":"^20.6.3","@types/node-forge":"^1.3.5","@vitest/coverage-v8":"^0.34.4","changelogen":"^0.5.5","eslint":"^8.49.0","eslint-config-unjs":"^0.2.1","ip-regex":"^5.0.0","prettier":"^3.0.3","typescript":"^5.2.2","unbuild":"^2.0.0","vitest":"^0.34.4"},"packageManager":"pnpm@8.7.4","gitHead":"7c2af5faf390d2a9ded7f68e5442eeed4ef09a2f","bugs":{"url":"https://github.com/unjs/listhen/issues"},"homepage":"https://github.com/unjs/listhen#readme","_id":"@vinxi/listhen@1.5.5","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-vSvw7Zw+foAsW9N6jki8trZDBBaqtwkf1nnG6rwZvRlkgqfNeSKUOrsI38DTXvZR4S4MzpwUSrWyG2lwTrilOw==","shasum":"1f69cf4193647d14e722298bc9a597af3e8c4821","tarball":"https://registry.npmjs.org/@vinxi/listhen/-/listhen-1.5.5.tgz","fileCount":20,"unpackedSize":168779,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCtjQnqKNCobxPYI68rLdMCOu9uY4rAzLggWIJq1DDQVgIgMBBnvgMUHEnUYijA+Q5QAPGwpwWyAv+USwAabn0T0/c="}]},"_npmUser":{"name":"nksaraf","email":"nsaraf98@gmail.com"},"directories":{},"maintainers":[{"name":"nksaraf","email":"nsaraf98@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/listhen_1.5.5_1695549210188_0.6652033115539957"},"_hasShrinkwrap":false},"1.5.6":{"name":"@vinxi/listhen","version":"1.5.6","description":"👂 Elegant HTTP Listener","repository":{"type":"git","url":"git+https://github.com/unjs/listhen.git"},"license":"MIT","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.mjs","require":"./dist/index.cjs"},"./cli":{"types":"./dist/cli.d.ts","import":"./dist/cli.mjs","require":"./dist/cli.cjs"}},"main":"./dist/index.mjs","types":"./dist/index.d.ts","bin":{"listen":"bin/listhen.mjs","listhen":"bin/listhen.mjs"},"scripts":{"build":"unbuild","dev":"vitest","lint":"eslint --ext .ts . && prettier -c src test","lint:fix":"eslint --fix --ext .ts . && prettier -w src test","listhen":"node ./scripts/listhen.mjs","play":"node ./scripts/listhen.mjs --ws -w ./playground","release":"pnpm test && pnpm build && changelogen --release && pnpm publish && git push --follow-tags","test":"pnpm lint && vitest run --coverage"},"dependencies":{"@parcel/watcher":"^2.3.0","@parcel/watcher-wasm":"2.3.0","citty":"^0.1.5","clipboardy":"^4.0.0","consola":"^3.2.3","defu":"^6.1.4","get-port-please":"^3.1.2","h3":"^1.10.0","http-shutdown":"^1.2.2","jiti":"^1.21.0","mlly":"^1.5.0","node-forge":"^1.3.1","pathe":"^1.1.2","std-env":"^3.7.0","ufo":"^1.3.2","untun":"^0.1.3","uqr":"^0.1.2"},"devDependencies":{"@types/node":"^20.11.0","@types/node-forge":"^1.3.11","@vitest/coverage-v8":"^1.2.0","changelogen":"^0.5.5","eslint":"^8.56.0","eslint-config-unjs":"^0.2.1","ip-regex":"^5.0.0","prettier":"^3.2.2","typescript":"^5.3.3","unbuild":"^2.0.0","vitest":"^1.2.0"},"packageManager":"pnpm@8.14.1","_id":"@vinxi/listhen@1.5.6","gitHead":"c89643b4b88482f0f873f6a83cfcc938db3b3498","bugs":{"url":"https://github.com/unjs/listhen/issues"},"homepage":"https://github.com/unjs/listhen#readme","_nodeVersion":"20.10.0","_npmVersion":"10.2.3","dist":{"integrity":"sha512-WSN1z931BtasZJlgPp704zJFnQFRg7yzSjkm3MzAWQYe4uXFXlFr1hc5Ac2zae5/HDOz5x1/zDM5Cb54vTCnWw==","shasum":"78a01eb6d92016b646f3b468433e7bbb8c9957ab","tarball":"https://registry.npmjs.org/@vinxi/listhen/-/listhen-1.5.6.tgz","fileCount":20,"unpackedSize":181726,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIE/Phgpe/Yl+Ow0+ALwQU9H70Crq1oPxPWs128oe1FvsAiEAv58dy5iryd3VPM58Ekz3vTvTvFdJfarnBgzUosdfl7E="}]},"_npmUser":{"name":"nksaraf","email":"nsaraf98@gmail.com"},"directories":{},"maintainers":[{"name":"nksaraf","email":"nsaraf98@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/listhen_1.5.6_1705338287249_0.8613687929969829"},"_hasShrinkwrap":false}},"time":{"created":"2023-09-24T09:53:30.087Z","1.5.5":"2023-09-24T09:53:30.393Z","modified":"2024-01-15T17:04:47.719Z","1.5.6":"2024-01-15T17:04:47.509Z"},"maintainers":[{"name":"nksaraf","email":"nsaraf98@gmail.com"}],"description":"👂 Elegant HTTP Listener","homepage":"https://github.com/unjs/listhen#readme","repository":{"type":"git","url":"git+https://github.com/unjs/listhen.git"},"bugs":{"url":"https://github.com/unjs/listhen/issues"},"license":"MIT","readme":"# 👂 listhen\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![Codecov][codecov-src]][codecov-href]\n[![License][license-src]][license-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\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, 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✅ 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(\"/\", eventHandler(() => \"Hello world!\"));\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### `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## License\n\nMIT. Made with 💖\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/listhen?style=flat&colorA=18181B&colorB=F0DB4F\n[npm-version-href]: https://npmjs.com/package/listhen\n[npm-downloads-src]: https://img.shields.io/npm/dm/listhen?style=flat&colorA=18181B&colorB=F0DB4F\n[npm-downloads-href]: https://npmjs.com/package/listhen\n[codecov-src]: https://img.shields.io/codecov/c/gh/unjs/listhen/main?style=flat&colorA=18181B&colorB=F0DB4F\n[codecov-href]: https://codecov.io/gh/unjs/listhen\n[license-src]: https://img.shields.io/github/license/unjs/listhen.svg?style=flat&colorA=18181B&colorB=F0DB4F\n[license-href]: https://github.com/unjs/listhen/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsDocs.io-reference-18181B?style=flat&colorA=18181B&colorB=F0DB4F\n[jsdocs-href]: https://www.jsdocs.io/package/listhen\n","readmeFilename":"README.md"}