Wait For Localhost Save

Wait for localhost to be ready

Project README

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.

Open Source Agenda is not affiliated with "Wait For Localhost" Project. README Source: sindresorhus/wait-for-localhost
Stars
272
Open Issues
2
Last Commit
1 year ago
License
MIT

Open Source Agenda Badge

Open Source Agenda Rating