get-server-address

Get the address of a server.

Usage no npm install needed!

<script type="module">
  import getServerAddress from 'https://cdn.skypack.dev/get-server-address';
</script>

README

get-server-address

Get the address of a server.

Installation

yarn

Usage

The following code will output: Listening at http://[::]:8888.

import {createServer} from 'http';

const server = createServer();

server.listen(8888, () => {
  const address = getServerAddress(server);
  console.log(`Listening at ${address}`);
});

Will work with express, connect or any other server that imitates Server from the net module.