npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, πŸ‘‹, I’m Ryan HefnerΒ  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you πŸ™

Β© 2024 – Pkg Stats / Ryan Hefner

@playlistduong/s-deploy

v1.0.0

Published

πŸ‘‚ Simple deploy like pm2

Downloads

2

Readme

πŸ‘‚ listhen

npm version npm downloads

Elegant HTTP listener!

πŸ‘‰ Online Playground

Features

βœ… Dev server with HMR, static, WebSockets and typescript support with unjs/jiti

βœ… Works with Node.js, express, and unjs/h3 out of the box

βœ… Show the QR code of the public URL with unjs/uqr

βœ… Tunnel your local server to the world with unjs/untun

βœ… Assign a port or fallback to a nicer alternative with unjs/get-port-please

βœ… Gracefully shutdown Server with http-shutdown

βœ… Zero Config WebSockets with unjs/crossws

βœ… Copy the URL to the clipboard

βœ… HTTPS support with self-signed certificates

βœ… Open URL in browser

βœ… Detect test and production environments to auto-adjust behavior

βœ… Close on the exit signal

Quick Usage (CLI)

You can run your applications in localhost with typescript support and watch mode using listhen CLI:

Create index.ts:

export default (req, res) => {
  res.end("Hello World!");
};

or using unjs/h3:

import { createApp, eventHandler } from "h3";

export const app = createApp();

app.use(
  "/",
  eventHandler(() => "Hello world!"),
);

or use npx to invoke listhen command:

npx listhen -w ./index.ts

Usage (API)

Install package:

# pnpm
pnpm i listhen

# npm
npm i listhen

# yarn
yarn add listhen

Import into your Node.js project:

// CommonJS
const { listen, listenAndWatch } = require("listhen");

// ESM
import { listen, listenAndWatch } from "listhen";
const handler = (req, res) => {
  res.end("Hi!")
}

// listener: { url, getURL, server, close, ... }
const listener = await listen(handler, options?)

Options

port

  • Default: process.env.PORT or 3000 or memorized random (see get-port-please)

Port to listen.

hostname

  • Default: process.env.HOST || '0.0.0.0'

Default hostname to listen.

https

  • Type: Boolean | Object
  • Default: false

Listen on HTTPS with SSL enabled.

Self-Signed Certificate

By setting https: true, listhen will use an auto-generated self-signed certificate.

You can set https to an object for custom options. Possible options:

  • domains: (Array) Default is ['localhost', '127.0.0.1', '::1'].
  • validityDays: (Number) Default is 1.

User-Provided Certificate

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.

To provide a certificate stored in a keystore set https: { pfx } with a path to the keystore. When the keystore is password protected also set passphrase.

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 a test environment)

Show a CLI message for the listening URL.

baseURL

  • Default: /

open

  • Default: false (force disabled on test and production environments)

Open the URL in the browser. Silently ignores errors.

clipboard

  • Default: false (force disabled on test and production environments)

Copy the URL to the clipboard. Silently ignores errors.

isTest

  • Default: process.env.NODE_ENV === 'test'

Detect if running in a test environment to disable some features.

autoClose

  • Default: true

Automatically close when an exit event, SIGTERM, SIGINT or SIGHUP 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.

ws

  • Default: false

Enable experimental WebSocket support using unjs/crossws or node upgrade handler.

Option can be a function for Node.js upgrade handler ((req, head) => void) or an Object to use CrossWS Hooks.

When using dev server CLI, you can easily use --ws and a named export called websocket to define CrossWS Hooks with HMR support!

License

Published under the MIT license. Made by @pi0 and community πŸ’›


πŸ€– auto updated with automd