Wait for localhost to be ready
Useful if you need a local server to be ready to accept requests before doing other things.
$ npm install --global wait-for-localhost
const waitForLocalhost = require('wait-for-localhost');
(async () => {
await waitForLocalhost({port: 8080});
console.log('Server is ready');
})();
Returns a Promise
that settles when localhost is ready.
Type: Object
Type: number
Default: 80
Type: boolean
Default: false
Use the GET
HTTP-method instead of HEAD
to check if the server is running.
- wait-for-localhost-cli - CLI for this module
- delay - Delay execution for a given amount of seconds
MIT © Sindre Sorhus