Package 'hotwater'

Title: Live Reload for Plumber APIs
Description: Enhances development for plumber APIs by enabling live reloading. Monitors API files for changes and automatically refreshes the server and connected web clients, allowing for faster API iteration.
Authors: Elian Thiele-Evans [aut, cre]
Maintainer: Elian Thiele-Evans <[email protected]>
License: GPL (>= 3)
Version: 0.0.0.9002
Built: 2025-01-14 05:08:03 UTC
Source: https://github.com/ElianHugh/hotwater

Help Index


Run hotwater from the command line

Description

Following install_hotwater(), the hotwater command can be used to run a hotwater engine straight from the terminal. See run() for further details on default values.

hotwater -v will provide the current version of hotwater. hotwater -h will provide help text.

Arguments

-f

plumber file

-d

extra directories

-p

plumber port

-h

show help

--host

plumber host

See Also

run()

Examples

# ```sh
# hotwater -f path/to/app.R -p 9999
# ```

Install global hotwater script

Description

If hotwater is installed, users may run hotwater from the command line rather than from an R terminal.

Usage

install_hotwater(install_folder)

Arguments

install_folder

folder to install hotwater script into. To run as expected, make sure that the folder supplied is on your PATH envar.

See Also

uninstall_hotwater

Examples

hotwater::install_hotwater()

Start a hotwater engine

Description

Start the hotwater engine, launching a plumber API that is restarted whenever a file in the plumber API's folder is modified.

Extra directories can be specified to refresh the API when directories other than the plumber folder are modified.

If a plumber endpoint returns an HTML response, when hotwater refreshes the API, {hotwater} will also order a refresh of any webpage that is using the API.

Usage

run(path, dirs = NULL, port = NULL, host = NULL, ignore = NULL)

Arguments

path

path to plumber API file.

dirs

(optional) a character vector of extra directories to watch for file changes. Paths are resolved from the current working directory, not the directory of the plumber API file.

port

[default httpuv::randomPort()] port to launch API on.

port can either be set explicitly, or it defaults to the plumber.port option. If the plumber option is undefined, the fallback value of httpuv::randomPort() is used.

host

[default "127.0.0.1"] host to launch API on.

host can either be set explicitly, or it defaults to the plumber.host option. If the plumber option is undefined, the fallback value of "127.0.0.1" is used.

ignore

[default c("*.sqlite", "*.git*")] vector of file globs to ignore.

Details

To refresh the browser, a postserialize plumber::pr_hook is used to inject a websocket into the HTML client that listens for the plumber server refresh.

See Also

plumber::options_plumber, plumber::get_option_or_env, plumber::serializer_html

Examples

# start a hotwater session on port 9999
 hotwater::run(
   path = system.file("examples", "plumber.R", package = "hotwater"),
   port = 9999L
 )

Uninstall global hotwater script

Description

Uninstall global hotwater script

Usage

uninstall_hotwater(install_folder)

Arguments

install_folder

folder to uninstall hotwater from.

See Also

install_hotwater

Examples

hotwater::uninstall_hotwater()