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

earlist

v0.0.3

Published

πŸ‘‚ An elegant HTTP listener.

Downloads

9

Readme

cover npm version npm downloads bundle JSDocs License

πŸ‘‚ earlist

πŸ‘‚ An elegant HTTP listener.

✨ Features

  • 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 scotty-beam-me-up) 🌐
  • 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 πŸ› οΈ

⚑️ Install

Install:

#nyxi
nyxi earlist

#pnpm
pnpm add earlist

#npm
npm i earlist

#yarn
yarn add earlist

Import into your Node.js project:

// CommonJS
const { listen } = require('earlist')

// ESM
import { listen } from 'earlist'

🎯 Usage

Function signature:

const { url, getURL, server, close } = await listen(handle, options?)

Plain handle function:

listen((_req, res) => {
   res.end('hi')
})

With express/connect:

const express = require('express')
const app = express()

app.use('/', ((_req, res) => {
  res.end('hi')
})

listen(app)

βš™οΈ Options

βš“οΈ port

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, earlist 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 cert and key are path to the ssl certificates.

You can also provide inline cert and key instead of reading from filesystem. In this case, they should start with --.

🌐 showURL

  • Default: true (force disabled on test environment)

Show a CLI message for listening URL.

🌐 baseURL

  • Default: /

πŸ” open

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

Open URL in browser. Silently ignores errors.

πŸ“‹ clipboard

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

Copy URL to 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 signal is received on process.

πŸ“œ License

MIT - Made with πŸ’ž