{"id":19488934,"url":"https://github.com/tableflowhq/db-webhooks","last_synced_at":"2025-04-15T13:41:20.451Z","repository":{"id":175652621,"uuid":"653827954","full_name":"tableflowhq/db-webhooks","owner":"tableflowhq","description":"Real-time events for Postgres","archived":false,"fork":false,"pushed_at":"2023-06-14T20:53:03.000Z","size":6998,"stargazers_count":40,"open_issues_count":3,"forks_count":7,"subscribers_count":4,"default_branch":"main","last_synced_at":"2025-03-28T20:37:26.475Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/tableflowhq.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":"2023-06-14T20:33:14.000Z","updated_at":"2025-02-23T01:09:32.000Z","dependencies_parsed_at":null,"dependency_job_id":"6fd5619c-9995-463e-a6bf-50a9d63ff93e","html_url":"https://github.com/tableflowhq/db-webhooks","commit_stats":null,"previous_names":["tableflowhq/db-webhooks"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflowhq%2Fdb-webhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflowhq%2Fdb-webhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflowhq%2Fdb-webhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/tableflowhq%2Fdb-webhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/tableflowhq","download_url":"https://codeload.github.com/tableflowhq/db-webhooks/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249081581,"owners_count":21209724,"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":"2024-11-10T21:06:35.421Z","updated_at":"2025-04-15T13:41:20.437Z","avatar_url":"https://github.com/tableflowhq.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003ch1 align=\"center\"\u003e🪝 DB Webhooks\u003c/h1\u003e \u003c/h1\u003e\n\u003cem\u003eReal-time events for Postgres\u003c/em\u003e\n\n\u003c/div\u003e\n\nDB Webhooks is a utility for Postgres that triggers webhooks when rows are inserted, updated, or deleted. It uses\ndatabase triggers that send low-latency websocket messages to a Go application. This application then calls\nthe configured webhook(s) with a JSON payload that includes specified values from the database row.\n\n### How It Works\n\n1. Data is modified in a Postgres table (INSERT, UPDATE, DELETE)\n2. A Postgres trigger notifies the DB Webhooks web server via a websocket message\n3. DB Webhooks formats, filters, and sends the data to configured webhook(s)\n\n![DB Webhooks Create Slack Notification](https://i.imgur.com/1xoorz9.gif)\n\n## Get Started\n\n### Run DB Webhooks locally\n\nYou can run DB Webhooks locally with Docker.\n\n```bash\ngit clone --depth 1 https://github.com/tableflowhq/db-webhooks.git\ncd db-webhooks\ndocker-compose up -d\n```\n\nThen open [http://localhost:3000](http://localhost:3000) to access DB Webhooks.\n\u003cbr\u003e\n\u003cbr\u003e\n**Note**: When connecting your database, if your Postgres host is `localhost`, you must use `host.docker.internal`\ninstead to access it when running with Docker.\n\n### Run DB Webhooks on AWS (EC2)\n\n**Note**: Make sure this instance is only accessible within your VPC.\\\n**Note**: Make sure your local machine is able to connect to the server on port 3000 (the web server) and 3003 (the API\nserver) over HTTP.\\\n**Note**: These instructions are for Amazon Linux 2 AMI (HVM).\n\n#### Option 1 (one-line install)\n\n```bash\nsudo yum update -y \u0026\u0026 \\\nsudo yum install -y docker \u0026\u0026 \\\nsudo service docker start \u0026\u0026 \\\nsudo usermod -a -G docker $USER \u0026\u0026 \\\nsudo curl -L \"https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s)-$(uname -m)\" -o /usr/local/bin/docker-compose \u0026\u0026 \\\nsudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose \u0026\u0026 \\\nsudo chmod +x /usr/bin/docker-compose \u0026\u0026 \\\nmkdir db-webhooks \u0026\u0026 cd db-webhooks \u0026\u0026 \\\nwget https://raw.githubusercontent.com/tableflowhq/db-webhooks/main/{.env,docker-compose.yml,.dockerignore,frontend.env} \u0026\u0026 \\\nsg docker -c 'docker-compose up -d'\n\n```\n\n#### Option 2 (guided install)\n\n1. To install Docker, run the following command in your SSH session on the instance terminal:\n\n```bash\nsudo yum update -y\nsudo yum install -y docker\nsudo service docker start\nsudo usermod -a -G docker $USER\nlogout # Needed to close the SSH session so Docker does not have to be run as root\n```\n\n2. To install `docker-compose`, run the following command in your ssh session on the instance terminal:\n\n```bash\nsudo curl -L \"https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-$(uname -s)-$(uname -m)\"  -o /usr/local/bin/docker-compose\nsudo mv /usr/local/bin/docker-compose /usr/bin/docker-compose\nsudo chmod +x /usr/bin/docker-compose\ndocker-compose version\n```\n\n3. Install and run DB Webhooks\n\n```bash\nmkdir db-webhooks \u0026\u0026 cd db-webhooks\nwget https://raw.githubusercontent.com/tableflowhq/db-webhooks/main/{.env,docker-compose.yml,.dockerignore,frontend.env}\ndocker-compose up -d\n```\n\n## Features\n\n### Template Strings\n\nEmbed variables from database rows in your actions\nWhen adding an action, you can insert data from the row into the response body of the POST request by using template\nstrings.\n\nFor instance, if your table has a column called `email`, you would put the value `${email}` in the request\nbody: `{\"text\":\"User created: ${email}!\"}`\n\nThe prefixes `new.` and `old.` can be used if a new (INSERT, UPDATE) or old (UPDATE, DELETE) row is available. If a\nprefix is not specified, the new or old values will be used depending on the event.\nExample: `{\"text\":\"User updated: ${old.email} is now ${new.email}!\"}`\n\nMeta values can also be used to get more query information. The following are available:\n\n1. `meta.table` (table name)\n2. `meta.schema` (schema name)\n3. `meta.event` (INSERT, UPDATE, or DELETE)\n4. `meta.user` (the Postgres user who ran the query that triggered the trigger)\n5. `meta.event_summary` (a formatted summary of the user, table, and event)\n6. `meta.changed` (the values changed for an UPDATE)\n\n## Postgres Configuration\n\n### Create a Postgres User\n\nWhen setting up your database in DB Webhooks, you'll need a Postgres user to connect to the database. You can either use\nan existing user or create a new one. This guide shows how to create a new Postgres user with the correct permissions\nneeded for DB Webhooks.\n\nIf you're using an existing user, make sure the user has the `create` permission on the schema(s) you want to use.\n\n**Note:** If you want DB Webhooks to also clean up the triggers and functions it creates when all actions are removed on\na table, the user needs to be an owner as Postgres does not have a \"drop\" permission.\n\n### Why is the `create` Permission Needed?\n\nDB Webhooks uses the create permission to create triggers and functions. A trigger (and corresponding function) is\ncreated whenever a new action on a table is added which doesn't have the DB Webhooks trigger already.\n\nDB Webhooks will delete the trigger and function it created if the last action on a table is removed, so it doesn't\nleave any extra triggers on your database.\n\nYou can see how the trigger works by looking at its implementation in `util.go`.\n\n#### 1. Create the User\n\n```sql\ncreate user db_webhooks with encrypted password 'XXXXXXXXXXXXXXX';\n```\n\n#### 2. Grant Create Access\n\n```sql\ngrant create on schema public to db_webhooks;\n-- If you have tables in a schema other than `public`, add the schema here\ngrant create on schema your_other_schema_if_needed to db_webhooks;\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflowhq%2Fdb-webhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftableflowhq%2Fdb-webhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftableflowhq%2Fdb-webhooks/lists"}