From: Ardis Lu Date: Mon, 11 Jul 2022 01:43:30 +0000 (-0700) Subject: Move wrangler bindings to .dev.vars X-Git-Url: https://git.ardis.lu/?a=commitdiff_plain;h=b64b652b01df042f41e3539e27b04e94805f5f3c;p=ardislu.dev Move wrangler bindings to .dev.vars Currently this is an undocumented feature only available in the beta --- diff --git a/.dev.vars.example b/.dev.vars.example new file mode 100644 index 0000000..63dc5c2 --- /dev/null +++ b/.dev.vars.example @@ -0,0 +1,3 @@ +EMAIL="example@example.com" +PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" +SCOPES="https://www.googleapis.com/auth/spreadsheets.readonly https://www.googleapis.com/auth/documents.readonly" diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..20bf020 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +.dev.vars +node_modules diff --git a/README.md b/README.md index e3dfcb9..5f98dbd 100644 --- a/README.md +++ b/README.md @@ -14,10 +14,10 @@ Once I fetch an article from the Google Docs API, the article is converted into ## Local development -Use the `wrangler` CLI to serve the static frontend and API at the same time. Provide credentials for a service account with access to the Google Docs as environment variables. +Use the `wrangler` CLI to serve the static frontend and API at the same time. -From the [Cloudflare Pages documentation](https://developers.cloudflare.com/pages/platform/functions/#develop-and-preview-locally): +1. Copy `.dev.vars.example` and rename it to `.dev.vars`. Provide an email and private key for a service account with access to the Google Docs and Google Sheet. -1. `npm i wrangler@beta` +2. `npm i wrangler@beta` -2. `npx wrangler pages dev . --binding EMAIL="example@example.com" PRIVATE_KEY="-----BEGIN PRIVATE KEY-----\n...EXAMPLE...\n-----END PRIVATE KEY-----\n" SCOPES="https://example.com/auth/scope1 https://example.com/auth/scope2"` +3. `npx wrangler pages dev .`