{"id":14066692,"url":"https://github.com/ThinkR-open/mariobox","last_synced_at":"2025-07-29T23:32:00.332Z","repository":{"id":69754293,"uuid":"521681142","full_name":"ThinkR-open/mariobox","owner":"ThinkR-open","description":" A Framework For Packaging {plumber} APIs","archived":false,"fork":false,"pushed_at":"2024-12-10T09:43:03.000Z","size":58,"stargazers_count":41,"open_issues_count":12,"forks_count":1,"subscribers_count":5,"default_branch":"main","last_synced_at":"2025-07-23T10:49:00.223Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"R","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ThinkR-open.png","metadata":{"files":{"readme":"README.Rmd","changelog":"NEWS.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2022-08-05T15:05:15.000Z","updated_at":"2025-07-11T14:38:25.000Z","dependencies_parsed_at":null,"dependency_job_id":"bf3bdb50-189f-42b7-b2ac-24f56f52deca","html_url":"https://github.com/ThinkR-open/mariobox","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ThinkR-open/mariobox","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fmariobox","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fmariobox/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fmariobox/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fmariobox/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ThinkR-open","download_url":"https://codeload.github.com/ThinkR-open/mariobox/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ThinkR-open%2Fmariobox/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267780014,"owners_count":24143201,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-29T02:00:12.549Z","response_time":2574,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-13T07:05:13.170Z","updated_at":"2025-07-29T23:31:59.963Z","avatar_url":"https://github.com/ThinkR-open.png","language":"R","funding_links":[],"categories":["R"],"sub_categories":[],"readme":"---\noutput: github_document\n---\n\n\u003c!-- README.md is generated from README.Rmd. Please edit that file --\u003e\n\n```{r, include = FALSE}\nknitr::opts_chunk$set(\n  collapse = TRUE,\n  comment = \" \",\n  fig.path = \"man/figures/README-\",\n  out.width = \"100%\"\n)\n\ncat_mariobox_yaml \u003c- function(path_pipo) {\n  cat(\n    paste0(\n      readLines(\n        file.path(path_pipo, \"inst/mariobox.yml\")\n      ),\n      \"\\n\"\n    )\n  )\n}\n```\n\n# {mariobox}\n\n\u003c!-- badges: start --\u003e\n[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html#experimental)\n[![CRAN status](https://www.r-pkg.org/badges/version/mariobox)](https://CRAN.R-project.org/package=mariobox)\n[![R-CMD-check](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/ThinkR-open/mariobox/actions/workflows/R-CMD-check.yaml)\n\u003c!-- badges: end --\u003e\n\n[DISCLAIMER] This is a Work In Progress, please use at your own risk. \n\nThe goal of `{mariobox}` is to provide a framework for packaging {plumber} APIs.\nThink of it as the \"`{golem}` for `{plumber}`\"\n\n## Installation\n\nYou can install the development version of `{mariobox}` from [GitHub](https://github.com/) with:\n\n``` r\n# install.packages(\"remotes\")\nremotes::install_github(\"ThinkR-Open/mariobox\")\n```\n\n## Example\n\n```{r}\nlibrary(mariobox)\n```\n\n### Creating a new {mariobox} project:\n\n```{r}\npath_pipo \u003c- tempfile(pattern = \"pipo\")\n\n# The create mariobox function will generate a new prefilled project\n# with everything you need to get your started\ncreate_mariobox(\n  path = path_pipo,\n  open = FALSE\n)\n```\n\nBy default, you'll find the following structure: \n\n```{r}\nfs::dir_tree(path_pipo)\n```\n\nThe default API comes with one default endpoint, `/health`, which returns a 200 with the \"ok\" text.\n\nWe've made the choice to organise your API inside a YAML, so that you can be as close as possible to a package structure. \n`{mariobox}` will then do a little bit of its magic and parse this YAML to build the `{plumber}` API.\n\n```{r, echo=FALSE}\ncat_mariobox_yaml(path_pipo)\n```\n\n### Add/Remove endpoints\n\n`{mariobox}` comes with a series of functions to add endpoints to your app. \nThe generic one is `add_endpoint`, that allows you to pass any HTTP verb, and add_get and friends are wrappers around this function.\n\n```{r}\nadd_endpoint(\n  name = \"allo\",\n  method = \"GET\",\n  open = FALSE,\n  pkg = path_pipo\n)\n```\n\nThis will produce the following R file: \n\n```{r echo = FALSE}\nreadLines(\n  file.path(\n    path_pipo,\n    \"R/get_allo.R\"\n  )\n) |\u003e cat(sep = \"\\n\")\n```\n\n```{r}\nadd_get(\n  name = \"hey\",\n  open = FALSE,\n  pkg = path_pipo\n)\n```\n\n```{r}\nfs::dir_tree(path_pipo)\n```\n\nThe YALML is automatically updated:\n\n```{r, echo=FALSE}\ncat_mariobox_yaml(path_pipo)\n```\n\n```{r}\nremove_endpoint(\n  name = \"allo\",\n  method = \"GET\",\n  pkg = path_pipo\n)\n```\n\n\n```{r}\nfs::dir_tree(path_pipo)\n```\n\nThe YALML is automatically updated:\n\n```{r, echo=FALSE}\ncat_mariobox_yaml(path_pipo)\n```\n\n### About endpoint functions\n\nAll endpoint functions will be in the following format: \n\n```{r eval = FALSE}\nMETHOD_NAME \u003c- function(req, res) {\n  METHOD_NAME_f()\n}\n\nMETHOD_NAME_f \u003c- function() {\n  return(\"ok\")\n}\n```\n\nwhere `METHOD` is the HTTP verb and `name` is the name you've set in your function. \n\nThis format might seem weird, but the idea is to separate the concerns in the following format: \n\n+ METHOD_NAME() will handle the http elements (login, headers..)\n+ METHOD_NAME_f() will be a standard function returning data.\n\nThat way, you can handle the data manipulation function just like a plain standard one, test it, interact with it, etc, without having to care about the HTTP part. \n\n## Running the API\n\nIn dev, you can launch the file at dev/run_dev.R. \n```{r eval = FALSE}\nsource(\"dev/run_dev.R\", echo = TRUE)\n```\n\nIn production, the `run_api()` is in charge of running the API. \n\nIf you want to deloy to RStudio Connect, the `build_plumber_file()` function will create a `plumber.R` file at the root of your folder. You can deploy using this file.\n\n```{r}\nbuild_plumber_file(pkg = path_pipo)\n```\n\nThis will produce the following file:\n\n```{r echo = FALSE}\nreadLines(\n  file.path(\n    path_pipo,\n    \"plumber.R\"\n  )\n) |\u003e cat(sep = \"\\n\")\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Fmariobox","html_url":"https://awesome.ecosyste.ms/projects/github.com%2FThinkR-open%2Fmariobox","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2FThinkR-open%2Fmariobox/lists"}