Skip to content

Bootstrap your Cloudflare Worker to connect to a pgEdge database

License

Notifications You must be signed in to change notification settings

myzie/cf-worker-template

 
 

Repository files navigation

cf-worker-template

Bootstrap your Cloudflare Worker to connect to a pgEdge database

Deploy to Cloudflare Workers

This is a simple Cloudflare Worker that connects to a pgEdge database. Use it as a starting point for your own project.

pgEdge connection

To find your pgEdge connection string, go to the pgEdge console. If you have not yet signed up for pgEdge, you can easily sign in with your social accounts. Creating a new database is free and takes less than a minute.

Once you've reached the console, navigate to the database you want to connect to. In the Connect to your database section, you will find your username, password, and the host is the Domain.

DB connection

The database connection is configured using the DB environment variable. The value should be in connection string format, e.g. postgres://user:pass@host/dbname?sslmode=required. This value can be added to Cloudflare using wrangler like so:

wrangler secret put DB

Additionally, you should make a .dev.vars file and set the DB environment variable there as well so that you can run the worker locally.

Cloudflare Token

You will need to set two repository secrets in your repo in order to deploy to Cloudflare. The first is CF_ACCOUNT_ID which is your Cloudflare account ID. The second is CF_API_TOKEN which is a token that you can generate from the API Tokens section of the Cloudflare dashboard.

About

Bootstrap your Cloudflare Worker to connect to a pgEdge database

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 100.0%