https://github.com/rjoydip/wait_for_localhost
Wait for localhost to be ready
https://github.com/rjoydip/wait_for_localhost
cli deno wait-for-localhost
Last synced: about 2 months ago
JSON representation
Wait for localhost to be ready
- Host: GitHub
- URL: https://github.com/rjoydip/wait_for_localhost
- Owner: rjoydip
- License: mit
- Created: 2022-10-30T05:37:49.000Z (over 3 years ago)
- Default Branch: master
- Last Pushed: 2022-10-30T05:37:58.000Z (over 3 years ago)
- Last Synced: 2025-03-30T16:25:34.736Z (about 1 year ago)
- Topics: cli, deno, wait-for-localhost
- Language: TypeScript
- Homepage:
- Size: 4.88 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: license
Awesome Lists containing this 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
```sh
deno install --allow-net -f --name wait_for_localhost https://deno.land/x/wait_for_localhost/cli.ts
```
## Usage CLI
```sh
$ wait_for_localhost
Example
$ wait_for_localhost 8000 && echo "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.
## Usage API
```ts
import { waitForLocalhost } from "https://deno.land/x/wait_for_localhost/mod.ts";
await waitForLocalhost({ port: 8000 });
console.log("Server is ready");
```
## Inspired
Inspired by [wait-for-localhost](https://github.com/sindresorhus/wait-for-localhost)
Inspired by [wait-for-localhost-cli](https://github.com/sindresorhus/wait-for-localhost-cli)
## License
MIT © [Joydip Roy](https://github.com/rjoydip)