You're Invited:Meet the Socket Team at BlackHat and DEF CON in Las Vegas, Aug 4-6.RSVP
Socket
Book a DemoInstallSign in
Socket

wait-for-localhost

Package Overview
Dependencies
Maintainers
1
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wait-for-localhost

Wait for localhost to be ready

4.1.0
latest
Source
npmnpm
Version published
Weekly downloads
3.7K
-11.91%
Maintainers
1
Weekly downloads
 
Created
Source

wait-for-localhost

Wait for localhost to be ready

Useful if you need a local server to be ready to accept requests before doing other things.

Install

npm install wait-for-localhost

Usage

import waitForLocalhost from 'wait-for-localhost';

await waitForLocalhost({port: 8080});
console.log('Server is ready');

API

waitForLocalHost(options?)

Returns a Promise<object> that settles when localhost is ready.

The object contains a ipVersion property with a value of either 6 or 4 depending on the IP version that was used.

options

Type: object

port

Type: number
Default: 80

path

Type: string
Default: '/'

Use a custom path.

For example, /health for a health-check endpoint.

useGet

Type: boolean
Default: false

Use the GET HTTP-method instead of HEAD to check if the server is running.

statusCodes

Type: number[]
Default: [200]

HTTP status codes to consider as successful responses.

  • wait-for-localhost-cli - CLI for this module
  • delay - Delay execution for a given amount of seconds

Keywords

wait

FAQs

Package last updated on 17 May 2024

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