https://github.com/sol-eng/plumbpkg
Example R package that includes Plumber APIs
https://github.com/sol-eng/plumbpkg
Last synced: about 1 month ago
JSON representation
Example R package that includes Plumber APIs
- Host: GitHub
- URL: https://github.com/sol-eng/plumbpkg
- Owner: sol-eng
- License: other
- Created: 2019-09-10T18:50:39.000Z (over 5 years ago)
- Default Branch: main
- Last Pushed: 2021-11-12T13:13:55.000Z (over 3 years ago)
- Last Synced: 2024-07-31T19:25:32.345Z (9 months ago)
- Language: R
- Size: 22.5 KB
- Stars: 48
- Watchers: 4
- Forks: 9
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- jimsghstars - sol-eng/plumbpkg - Example R package that includes Plumber APIs (R)
README
# plumbpkg
[](https://travis-ci.org/sol-eng/plumbpkg)
This is a simple package illustrating how to incorporate
[Plumber](https://www.rplumber.io) APIs into an R package. There are two main
motivations behind this example:1. Demonstrate how to build Plumber APIs into a package
2. Demonstrate how to test Plumber APIs using [testthat](https://testthat.r-lib.org)## Installation
```r
# install.packages("remotes")
remotes::install_github("sol-eng/plumbpkg")
```## Architecture
The design of this package is heavily influenced by [this
discussion](https://community.rstudio.com/t/plumber-api-and-package-structure/18099)
on RStudio Community.```
── DESCRIPTION
├── LICENSE
├── LICENSE.md
├── NAMESPACE
├── R
│ ├── api1.R
│ └── api2.R
├── README.md
├── inst
│ └── plumber
│ ├── api1
│ │ └── plumber.R
│ └── api2
│ ├── entrypoint.R
│ └── plumber.R
├── man
├── plumbpkg.Rproj
└── tests
├── testthat
│ ├── test-api1.R
│ ├── test-api2.R
│ └── test-plumber.R
└── testthat.R
```The `R/` directory contains all of the R functions used in the Plumber APIs.
This enables the functions to be tested using files in the `tests/` directory.
The Plumber APIs are defined in files in `inst/plumber/` and are also tested
using testthat and [httr](https://httr.r-lib.org).## Deploy
This repository deploys both APIs to [RStudio
Connect](https://www.rstudio.com/products/connect/) using
[Travis](https://travis-ci.org/). The deployment is managed by
[`scripts/deploy-rsc.sh`](scripts/deploy-rsc.sh) and uses the RStudio Connect
API. Because this repository uses Travis, the APIs will only be deployed
**after** tests have successfully completed.There are certainly other ways this content could be deployed, either using
other CI/CD solutions or using [RStudio Connect's ability to publish content
from a git
repository](https://docs.rstudio.com/connect/1.7.6/user/git-backed.html).