All Projects β†’ cloudflare β†’ worker-template-postgres

cloudflare / worker-template-postgres

Licence: Apache-2.0, MIT licenses found Licenses found Apache-2.0 LICENSE_APACHE MIT LICENSE_MIT
Reference demo and modified PostgreSQL driver to connect Cloudflare Workers to a relational database.

Programming Languages

javascript
184084 projects - #8 most used programming language
typescript
32286 projects
python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to worker-template-postgres

viteflare
Cloudflare workers meet Vite plugins
Stars: ✭ 35 (-53.33%)
Mutual labels:  workers, cloudflare
vite-plugin-cloudflare
πŸ”₯Building Cloudflare workers is faster and easier using vite-plugin-cloudflare with node builtins like process and stream
Stars: ✭ 108 (+44%)
Mutual labels:  workers, cloudflare
cloudflare-worker-router
A super lightweight router (1.3K) with middleware support and ZERO dependencies for CloudFlare Workers.
Stars: ✭ 144 (+92%)
Mutual labels:  workers, cloudflare
Worker Typescript Template
Κ• β€’ΜΨˆβ€’Μ€) TypeScript template for Cloudflare Workers
Stars: ✭ 129 (+72%)
Mutual labels:  workers, cloudflare
Cfworker
A collection of packages optimized for Cloudflare Workers and service workers.
Stars: ✭ 152 (+102.67%)
Mutual labels:  workers, cloudflare
natural
Fastest Framework for NodeJS. Written in pure ES6+
Stars: ✭ 30 (-60%)
Mutual labels:  workers, cloudflare
workers-jwt
Generate JWTs on Cloudflare Workers using the WebCrypto API
Stars: ✭ 67 (-10.67%)
Mutual labels:  workers, cloudflare
Create Google Shared Drive
Cloudflare Redesigned Script for creating a Shared/Team Drive
Stars: ✭ 93 (+24%)
Mutual labels:  workers, cloudflare
Google Drive Index
Index Google Drive Files Easily and Free
Stars: ✭ 205 (+173.33%)
Mutual labels:  workers, cloudflare
cloudflare-worker-rest-api
A cloudflare worker module which helps building REST Api quickly and easily, similar to express framework.
Stars: ✭ 31 (-58.67%)
Mutual labels:  workers, cloudflare
cloudflare-worker-graphql-ws-template
A template for WebSockets powered Cloudflare Worker project using graphql-ws
Stars: ✭ 21 (-72%)
Mutual labels:  workers, cloudflare
Serverless Cloudflare Workers
Serverless provider plugin for Cloudflare Workers
Stars: ✭ 114 (+52%)
Mutual labels:  workers, cloudflare
Tiny Worker
Tiny WebWorker for the Server
Stars: ✭ 196 (+161.33%)
Mutual labels:  workers
Meteor Service Worker
An universal service worker for meteor apps
Stars: ✭ 132 (+76%)
Mutual labels:  workers
Simpleue
PHP queue worker and consumer - Ready for AWS SQS, Redis, Beanstalkd and others.
Stars: ✭ 124 (+65.33%)
Mutual labels:  workers
DDos-Attack-OVH-
Powerful DDoS Attack
Stars: ✭ 155 (+106.67%)
Mutual labels:  cloudflare
Task bunny
TaskBunny is a background processing application written in Elixir and uses RabbitMQ as a messaging backend
Stars: ✭ 193 (+157.33%)
Mutual labels:  workers
Workq
Job server in Go
Stars: ✭ 1,546 (+1961.33%)
Mutual labels:  workers
Kafka Flow
KafkaFlow is a .NET framework to consume and produce Kafka messages with multi-threading support. It's very simple to use and very extendable. You just need to install, configure, start/stop the bus with your app and create a middleware/handler to process the messages.
Stars: ✭ 118 (+57.33%)
Mutual labels:  workers
Dtcqueuebundle
Symfony2/3/4/5 Queue Bundle (for background jobs) supporting Mongo (Doctrine ODM), Mysql (and any Doctrine ORM), RabbitMQ, Beanstalkd, Redis, and ... {write your own}
Stars: ✭ 115 (+53.33%)
Mutual labels:  workers

Cloudflare Workers + PostgreSQL

This repo contains example code and a PostgreSQL driver that can be used in any Workers project. If you are interested in using the driver outside of this template, copy the driver/postgres module into your project's node_modules or directly alongside your source.

Usage

Before you start, please refer to the official tutorial.

const client = new Client({
    user: '<DATABASE_USER>',
    database: '<DATABASE_NAME>',
    // hostname is the full URL to your pre-created Cloudflare Tunnel, see documentation here:
    // https://developers.cloudflare.com/cloudflare-one/connections/connect-apps/create-tunnel
    hostname: env.TUNNEL_HOST || 'https://dev.example.com',
    password: env.DATABASE_PASSWORD, // use a secret to store passwords
    port: '<DATABASE_PORT>',
})

await client.connect()

Please Note:

  • you must use this config object format vs. a database connection string
  • the hostname property must be the URL to your Cloudflare Tunnel, NOT your database host
    • your Tunnel will be configured to connect to your database host

Running the Postgres Demo

postgres/docker-compose.yml

This docker-compose composition will get you up and running with a local instance of postgresql, pgbouncer in front to provide connection pooling, and a copy of cloudflared to enable your applications to securely connect, through a encrypted tunnel, without opening any ports up locally.

Usage

from within scripts/postgres, run:

  1. Create credentials file (first time only)
docker run -v ~/.cloudflared:/etc/cloudflared cloudflare/cloudflared:2021.10.5 login
  1. Start a local dev stack (cloudflared/pgbouncer/postgres)
TUNNEL_HOSTNAME=dev.example.com docker-compose up
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].