service-port

1.0.0 • Public • Published

service-port

Map a service name to a port number. Use instead of hard-coding port numbers when running services locally.

npm install service-port

Usage

The module hashes a name to a valid port number, excluding values registered with IANA.

var port = require('service-port');
console.log(port('my-service'));

The above will always print 7935. As an optional second argument the module accepts a protocol name (e.g. tcp, udp or sctp), which is used to filter out reserved port numbers for that protocol. It defaults to tcp.

console.log(port('my-service', 'tcp')); // prints 7935
console.log(port('my-service', 'udp')); // prints 59577

Package Sidebar

Install

npm i service-port

Weekly Downloads

3

Version

1.0.0

License

MIT

Last publish

Collaborators

  • kapetan