Socket
Socket
Sign inDemoInstall

listhen

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

listhen - npm Package Compare versions

Comparing version 1.2.2 to 1.3.0

44

dist/cli.d.ts

@@ -44,2 +44,26 @@ import * as citty from 'citty';

};
"https.cert": {
type: "string";
description: string;
};
"https.key": {
type: "string";
description: string;
};
"https.pfx": {
type: "string";
description: string;
};
"https.passphrase": {
type: "string";
description: string;
};
"https.validityDays": {
type: "string";
description: string;
};
"https.domains": {
type: "string";
description: string;
};
watch: {

@@ -51,2 +75,22 @@ type: "boolean";

};
publicURL: {
type: "string";
description: string;
required: false;
};
qr: {
type: "boolean";
description: string;
required: false;
};
public: {
type: "boolean";
description: string;
required: false;
};
tunnel: {
type: "boolean";
description: string;
required: false;
};
}>;

@@ -53,0 +97,0 @@ declare const runMain: () => Promise<void>;

41

dist/index.d.ts

@@ -22,3 +22,3 @@ import { Server, RequestListener } from 'node:http';

name: string;
port?: GetPortInput;
port: GetPortInput;
hostname: string;

@@ -33,7 +33,30 @@ showURL: boolean;

autoClose: boolean;
autoCloseSignals: string[];
_entry?: string;
/**
* Used as main public url to display
* @default The first public IPV4 address listening to
*/
publicURL?: string;
/**
* Print QR Code for public IPv4 address
*
* @default true
*/
qr?: boolean;
/**
* When enabled, listhen tries to listen to all network interfaces
*
* @default `false` for development and `true` for production
*/
public: boolean;
/**
* Open a tunnel using https://github.com/unjs/untun
*/
tunnel?: boolean;
}
interface ShowURLOptions {
baseURL: string;
name?: string;
type GetURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "publicURL">;
type ShowURLOptions = Pick<Partial<ListenOptions>, "baseURL" | "name" | "publicURL" | "qr">;
interface ListenURL {
url: string;
type: "local" | "network" | "tunnel";
}

@@ -47,6 +70,7 @@ interface Listener {

open: () => Promise<void>;
showURL: (options?: Pick<ListenOptions, "baseURL">) => void;
showURL: (options?: ShowURLOptions) => Promise<void>;
getURLs: (options?: GetURLOptions) => Promise<ListenURL[]>;
}
declare function listen(handle: RequestListener, options_?: Partial<ListenOptions>): Promise<Listener>;
declare function listen(handle: RequestListener, _options?: Partial<ListenOptions>): Promise<Listener>;

@@ -69,2 +93,3 @@ interface DevServerOptions {

reload: (_initial?: boolean) => Promise<void>;
_entry: string | undefined;
}>;

@@ -80,2 +105,2 @@

export { Certificate, DevServerOptions, HTTPSOptions, ListenOptions, Listener, ShowURLOptions, WatchOptions, createDevServer, listen, listenAndWatch };
export { Certificate, DevServerOptions, GetURLOptions, HTTPSOptions, ListenOptions, ListenURL, Listener, ShowURLOptions, WatchOptions, createDevServer, listen, listenAndWatch };

17

package.json
{
"name": "listhen",
"version": "1.2.2",
"version": "1.3.0",
"description": "👂 Elegant HTTP Listener",

@@ -31,2 +31,3 @@ "repository": "unjs/listhen",

"dependencies": {
"@parcel/watcher": "^2.2.0",
"@parcel/watcher-wasm": "2.3.0-alpha.1",

@@ -38,3 +39,3 @@ "citty": "^0.1.2",

"get-port-please": "^3.0.1",
"h3": "^1.8.0-rc.2",
"h3": "^1.8.0-rc.3",
"http-shutdown": "^1.2.2",

@@ -45,13 +46,15 @@ "jiti": "^1.19.1",

"pathe": "^1.1.1",
"ufo": "^1.2.0"
"ufo": "^1.2.0",
"untun": "^0.1.1",
"uqr": "^0.1.0"
},
"devDependencies": {
"@types/node": "^20.4.5",
"@types/node": "^20.4.10",
"@types/node-forge": "^1.3.4",
"@vitest/coverage-v8": "^0.34.1",
"changelogen": "^0.5.4",
"eslint": "^8.46.0",
"eslint": "^8.47.0",
"eslint-config-unjs": "^0.2.1",
"ip-regex": "^5.0.0",
"prettier": "^3.0.0",
"prettier": "^3.0.1",
"typescript": "^5.1.6",

@@ -61,3 +64,3 @@ "unbuild": "^2.0.0-rc.0",

},
"packageManager": "pnpm@8.6.10",
"packageManager": "pnpm@8.6.12",
"scripts": {

@@ -64,0 +67,0 @@ "build": "unbuild",

# 👂 listhen
An elegant HTTP listener.
[![npm version][npm-version-src]][npm-version-href]

@@ -11,17 +9,34 @@ [![npm downloads][npm-downloads-src]][npm-downloads-href]

Elegant HTTP listener!
[👉 Online Playground](https://stackblitz.com/github/unjs/listhen/tree/main/playground?startScript=dev)
## Features
- Built-in CLI To run your applications with watch mode and typescript support (with [unjs/jiti](https://github.com/unjs/jiti)) and serve static files
- Promisified interface for listening and closing server
- Work with express/connect or plain http handle function
- Support HTTP and HTTPS
- Assign a port or fallback to human friendly alternative (with [unjs/get-port-please](https://github.com/unjs/get-port-please))
- Generate listening URL and show on console
- Copy URL to clipboard (dev only by default)
- Open URL in browser (opt-in)
- Generate self-signed certificate
- Detect test and production environments
- Close on exit signal
- Gracefully shutdown server with [http-shutdown](https://github.com/thedillonb/http-shutdown)
✅ Dev server with HMR, static, and typescript support with <a href="https://github.com/unjs/jiti">unjs/jiti</a><br>
✅ Works with Node.js, express, and <a href="https://github.com/unjs/h3">unjs/h3</a> out of the box <br>
✅ Show the QR code of the public URL with <a href="https://github.com/unjs/uqr">unjs/uqr</a><br>
✅ Tunnel your local server to the world with <a href="https://github.com/unjs/untun">unjs/untun</a><br>
✅ Assign a port or fallback to a nicer alternative with <a href="https://github.com/unjs/get-port-please">unjs/get-port-please</a>
✅ Gracefully shutdown Server with <a href="https://github.com/thedillonb/http-shutdown">http-shutdown</a><br>
✅ Copy the URL to the clipboard<br>
✅ HTTPS support with self-signed certificates<br>
✅ Open URL in browser<br>
✅ Detect test and production environments to auto-adjust behavior<br>
✅ Close on the exit signal<br>
<div align="center">
<img width="100%" src="./.assets/screenshot.png">
</div>
## Quick Usage (CLI)

@@ -39,3 +54,3 @@

Using [unjs/h3](https://github.com/unjs/h3):
or using [unjs/h3](https://github.com/unjs/h3):

@@ -50,3 +65,3 @@ ```ts

Use npx to invoke `listhen` command:
or use npx to invoke `listhen` command:

@@ -111,7 +126,7 @@ ```sh

Listen on https with SSL enabled.
Listen on HTTPS with SSL enabled.
#### Self Signed Certificate
#### Self-Signed Certificate
By setting `https: true`, listhen will use an auto generated self-signed certificate.
By setting `https: true`, listhen will use an auto-generated self-signed certificate.

@@ -123,6 +138,6 @@ You can set https to an object for custom options. Possible options:

#### User Provided Certificate
#### User-Provided Certificate
Set `https: { cert, key }` where cert and key are path to the ssl certificates.
With an encrypted private key you also need to set `passphrase` on the `https` object.
Set `https: { cert, key }` where the cert and key are paths to the SSL certificates.
With an encrypted private key, you also need to set `passphrase` on the `https` object.

@@ -132,9 +147,9 @@ To provide a certificate stored in a keystore set `https: { pfx }` with a path to the keystore.

You can also provide inline cert and key instead of reading from filesystem. In this case, they should start with `--`.
You can also provide an inline cert and key instead of reading from the filesystem. In this case, they should start with `--`.
### `showURL`
- Default: `true` (force disabled on test environment)
- Default: `true` (force disabled on a test environment)
Show a CLI message for listening URL.
Show a CLI message for the listening URL.

@@ -149,3 +164,3 @@ ### `baseURL`

Open URL in browser. Silently ignores errors.
Open the URL in the browser. Silently ignores errors.

@@ -156,3 +171,3 @@ ### `clipboard`

Copy URL to clipboard. Silently ignores errors.
Copy the URL to the clipboard. Silently ignores errors.

@@ -169,4 +184,22 @@ ### `isTest`

Automatically close when an exit signal is received on process.
Automatically close when an exit signal is received in the process.
### `publicURL`
- Default: (the first public URL listening)
The public URL to show in the CLI output
### `qr`
- Default: `true`
Print QR Code for public address.
### `public`
- Default: `false` for development or when `hostname` is `localhost` and `true` for production
When enabled, listhen tries to listen to all network interfaces. You can also enable this option using `--host` CLI flag.
## License

@@ -173,0 +206,0 @@

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc