wait-for-localhost
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.0 • Public • Published

    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 that settles when localhost is ready.

    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.

    Related

    Install

    npm i wait-for-localhost

    DownloadsWeekly Downloads

    2,605

    Version

    4.0.0

    License

    MIT

    Unpacked Size

    3.94 kB

    Total Files

    5

    Last publish

    Collaborators

    • sindresorhus