polishedapi
R package# R
# read in your database credentials
db_config <- config::get(file = "inst/plumber/api/config.yml")$db
# connect to your PostgreSQL database
db_conn <- polishedapi::db_connect(db_config)
# create the "polished" schema.
# Warning: if you already have a polished schema this function will overwrite
# your existing schema with empty tables.
polishedapi::create_schema(db_conn)
# create your account. e.g. my account can be created like so:
account <- polishedapi::add_account(
db_conn,
email = "andy.merlino@tychobra.com",
host_secret = "my_super_secret"
)
# replace my email ("andy.merlino@tychobra.com") above with your email, and
# replace the "host_secret" with the host secret that you deploy with your polishedapi.
Add your database credentials to "inst/plumber/api/config.yml". This is where your "host_secret" needs to be stored as your "polished_hosted_secret"."
Build the polished API Docker image.
# terminal
# build the docker image
docker build -t polished_api ./inst/plumber
# run the docker container. This is useful for local testing.
docker run --rm -p 8080:8080 polished_api
Note: Open bash shell inside running docker container. This is useful for debugging.
# terminal
docker exec -it $(docker ps -q) /bin/bash
Note: if you run several docker containers on your local computer, you may end up leaving some of them running by accident. You can clean up all running Docker container with the collowing command:
# terminal
# cleanup running containers
docker stop $(docker ps -q)
# tag image for deployment to GCR (Google Container Registry)
docker tag polished_api gcr.io/postgres-db-189513/polished_api
# push tagged image to GCR
docker push gcr.io/postgres-db-189513/polished_api
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.