2.0.9 • Published 2 years ago

listening-on v2.0.9

Weekly downloads
-
License
BSD-2-Clause
Repository
github
Last release
2 years ago

listening-on

Print server url with local and network ip address

npm Package Version npm Package Version npm Package Version

Plain node.js alternative to running-at.

This package doesn't rely on execa and ip, hence more portable.

Installation

## with npm
npm i listening-on

## or with pnpm
pnpm i listening-on

## or with yarn
yarn add listening-on

Usage Example

Named import example:

import express from 'express'
import { print } from 'listening-on'

const PORT = +process.env.PORT! || 3000
const app = express()

app.use(express.static('public'))

app.listen(PORT, () => {
  print(PORT)
  /* will print out below lines:
listening on http://127.0.0.1:8100 (lo)
listening on http://192.168.59.46:8100 (wlp3s0)
    */
})

commonjs compatible import example:

import * as listeningOn from 'listening-on'

listeningOn.print(PORT)

// or simply use require
require('listening-on').print(PORT)

Typescript Signature

export function print(port_or_options: number | PrintOptions): void

export type PrintOptions = {
  port: number
  // default http
  protocol?: Protocol | string
  // default IPv4
  family?: Family | 'all'
}

export type Protocol = 'http' | 'https' | 'ws' | 'wss' | 'tcp' | 'udp'

export type Family = 'IPv4' | 'IPv6'

License

This is free and open-source software (FOSS) with BSD-2-Clause License

2.0.9

2 years ago

2.0.8

2 years ago

2.0.3

2 years ago

2.0.5

2 years ago

2.0.4

2 years ago

2.0.7

2 years ago

2.0.6

2 years ago

2.0.2

3 years ago

2.0.1

3 years ago

2.0.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago