Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-listening-server

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-listening-server

Promise-based API to create listening `http.Server` instances.

  • 0.1.1
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
533
decreased by-68.14%
Maintainers
1
Weekly downloads
 
Created
Source

create-listening-server

Build Status npm version

Promise-based API to create listening http.Server instances.

Safe creation functionality is also exposed, with automated consecutive port retries when "address in use" errors occur. Useful for tests and development mode.

Getting started

Install the library in an existing project:

yarn add create-listening-server

Example usage

Creation of an http.Server with a specific port:

import { createListeningHttpServer } from 'create-listening-server'
import express from 'express'

const PORT = 3000

async function main() {
    const app = express()
    app.use(/* middleware */)

    const httpServer = await createListeningHttpServer(PORT, app)
}

Creation of an http.Server with automated consecutive ports retries:

import { safeListeningHttpServer } from 'create-listening-server'
import express from 'express'

const PREFERRED_PORT = 3000

async function main() {
    const app = express()
    app.use(/* middleware */)

    const {httpServer, port} = await safeListeningHttpServer(PREFERRED_PORT, app)
}

License

MIT

FAQs

Package last updated on 30 Nov 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc