server-address
TypeScript icon, indicating that this package has built-in type declarations

3.0.1 • Public • Published

Server Address

NPM version NPM Downloads Build status Test coverage

Listen to a randomly available port and resolve URLs relative to the server address.

Installation

npm install server-address --save

Usage

import { ServerAddress } from "server-address";
import * as express from "express";
 
const app = express();
const server = new ServerAddress(app);
 
// Listen to randomly available port.
server.listen();
 
server.url("/foo"); //=> "http://127.0.0.1:58933/foo"
 
// Close the server connection.
server.close();

Note: listen and close can optionally accept callback functions.

License

MIT license

Package Sidebar

Install

npm i server-address

Weekly Downloads

14

Version

3.0.1

License

MIT

Unpacked Size

21.9 kB

Total Files

9

Last publish

Collaborators

  • blakeembrey