{"id":24390412,"url":"https://github.com/pgedge/cloudflare-worker-template","last_synced_at":"2025-04-11T09:15:42.008Z","repository":{"id":215692116,"uuid":"739524015","full_name":"pgEdge/cloudflare-worker-template","owner":"pgEdge","description":"Bootstrap your Cloudflare Worker to connect to a pgEdge database","archived":false,"fork":false,"pushed_at":"2025-03-05T16:44:36.000Z","size":37,"stargazers_count":2,"open_issues_count":0,"forks_count":13,"subscribers_count":17,"default_branch":"main","last_synced_at":"2025-03-25T06:33:30.320Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/pgEdge.png","metadata":{"files":{"readme":"README.md","changelog":null,"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}},"created_at":"2024-01-05T19:19:44.000Z","updated_at":"2025-01-17T14:50:23.000Z","dependencies_parsed_at":"2025-01-17T15:34:00.880Z","dependency_job_id":null,"html_url":"https://github.com/pgEdge/cloudflare-worker-template","commit_stats":null,"previous_names":["pgedge/cf-worker-template","pgedge/cloudflare-worker-template"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fcloudflare-worker-template","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fcloudflare-worker-template/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fcloudflare-worker-template/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/pgEdge%2Fcloudflare-worker-template/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/pgEdge","download_url":"https://codeload.github.com/pgEdge/cloudflare-worker-template/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248366196,"owners_count":21091924,"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","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":"2025-01-19T16:17:24.193Z","updated_at":"2025-04-11T09:15:41.969Z","avatar_url":"https://github.com/pgEdge.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cloudflare-worker-template\nBootstrap your Cloudflare Worker to connect to a pgEdge database.\n\n[![Deploy to Cloudflare Workers](https://deploy.workers.cloudflare.com/button)](https://deploy.workers.cloudflare.com/?url=https://github.com/pgEdge/cloudflare-worker-template)\n\nThis is a simple Cloudflare Worker that connects to a pgEdge database. Use it as a starting point \nfor your own project! Simply click on the button above to deploy this worker to your Cloudflare\naccount and create a Github repository for it.\n\n## pgEdge connection\n\nThe easiest way to get your worker connected to a pgEdge database is to go to the [pgEdge console](https://app.pgedge.com).\nIf you have not yet signed up for pgEdge, you can easily sign in with your social accounts. Creating a new \ndatabase is free and takes less than a minute.\n\nOnce you've connected the console, navigate to the database you want to connect to. On the sidebar, click\non the \"Integrations\" tab. You should see a \"Cloudflare Workers\" integration. This will provide you with\nall the details you need to connect your worker to your database.\n\nIf you prefer to follow READMEs instead of clicking around, here are the steps to get your worker connected...\n\n### Setup your local environment\n\nOnce you've deployed your worker and cloned your repository, you'll need to setup your local environment to \nbe able to run the worker locally. You'll need to install [wrangler](https://developers.cloudflare.com/workers/wrangler/), the Cloudflare CLI tool.\n\nThe simplest way to install `wrangler` is to use `npm` to install dependencies:\n```bash\nnpm install\n```\n\nNote that `wrangler` requires a Node version of `16.17.0` or later.\n\n### DB connection\n\nThe database connection is configured using the `DB` environment variable. The value should be in\nconnection string format, e.g. `postgres://user:pass@host/dbname?sslmode=required`. This value\ncan be added to Cloudflare using one of the `npm` scripts like so:\n\n```bash\nnpm run add-db-secret\n```\n\nThe value to enter is the connection string from the pgEdge console. This can be found on the Integrations\ntab of your database under the Cloudflare Workers integration, or on the database details page under the \n\"Connect to your database\" section.  The \"Nearest Node\" tab will provide you with the connection string.\n\n### Add your local secret\n\nAdditionally, you should create a `.dev.vars` file and set the `DB` environment variable there as well\nso that you can run the worker locally.\n\n```bash\nDB=postgres://user:pass@host/dbname?sslmode=required\n```\n\n### Run your worker locally\n\nYou can run your worker locally using an `npm` script:\n\n```bash\nnpm run dev\n```\n\nOr you can use the Cloudflare dashboard to navigate to your worker and\nfind the deployed worker's URL.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgedge%2Fcloudflare-worker-template","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpgedge%2Fcloudflare-worker-template","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpgedge%2Fcloudflare-worker-template/lists"}