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

1.0.1 • Public • Published

devlisten

Given a requestListener (a function you can pass to http.createServer), set up a TCP/IP server which listens on a free port, and a UNIX socket in the BOXEN_SOCKET_DIR. Once done, invokes the callback with strings describing all the addresses through which the application is reachable.

This function is useful during development, hence its name devlisten. It won't do anything stupid in production, but because it uses a non-deterministic IP port, it's probably not that useful there.

Since frameworks like express, connect, koa expose an interface which is compatible with requestListener, you can pass those directly to devlisten.

Example

const app = express();

devlisten('catalog', app, (err, addresses) => {
  console.log(`Listening on ${addresses.join(', ')}`);
});

Readme

Keywords

none

Package Sidebar

Install

npm i devlisten

Weekly Downloads

1

Version

1.0.1

License

MIT

Last publish

Collaborators

  • werehamster