r/Supabase • u/Savings-Feedback6581 • 1d ago
Self-hosting What if your existing PostgreSQL database had its own HTTP API?
I have been working on HTTP Postgres, an open source project that allows you to run SQL queries against your PostgreSQL database over HTTP.
The concept is very simple. Rather than running TCP connections to the database from serverless functions or edge runtimes, you deploy a small gateway along with your PostgreSQL that takes care of connections for you.
Unlike PostgREST, which gives you access to your database via REST endpoints, my goal with this project is executing raw and parameterized SQL over HTTP.
Some of the features available today include:
- PostgreSQL connection pooling
- Parameterized queries and transactions
- Scoped API keys
- Rate limiting and IP allowlisting
- Query analytics and operational metrics
- Optional Redis integration
- Graceful overload handling
It is fully self-hosted and connects to your existing PostgreSQL database.
This is neither a replacement of PostgreSQL nor Supabase, it just makes PostgreSQL available over another transport layer.
Website & Documentation: https://http-postgres.js.org/
GitHub: https://github.com/http-postgres/http-postgres
I am really curious to know what do you think of such an approach, specifically from serverless and edge developers point of view?
What is stopping you from using something like that?
9
u/Neither_Worth3542 1d ago
postgrest's problem was never rest, it's that nobody wants their schema reachable from the internet. raw sql over http just makes the blast radius bigger with less typing.
6
u/lgastako 1d ago
Feels like a solution in search of a problem to me.
3
u/GeneDear1444 1d ago
Rate limiting, IP allowlisting, scoped keys, query analytics... that's an API gateway, not a transport layer. PostgREST gets away with calling itself thin because it actually is.
2
u/StreetTrash6166 1d ago
so the fix for "i dont want to manage TCP connections" is a new service i have to manage, which also wants redis, an api key store, a rate limiter and a metrics backend. thats like four more contianers to keep alive so i can avoid pgbouncer, which is one. and you call it "just another transport layer" two lines after listing rate limiting and query analytics, thats not a transport layer, thats a control plane and now i'm the one operating it.
who is this actually for though. on workers hyperdrive already pools for you, on lambda you can hoist the connection outside the handler or point at supavisor, and neon and supabase both already hand you an http data api. sure, raw sql beats postgrest's rest endpoints, i'll give you that, but you pay for it with every query going through your own gateway thats now a single point of failure i have to upgrade on a saturday
1
u/Savings-Feedback6581 1d ago edited 1d ago
guys you can also connect your AI to the MCP server and ask it to analyze the project and explain how everything works
https://http-postgres.harshcodez.com/mcp
1
u/Tricky-Oil6826 1d ago
Scoped API keys, on something whose whole job is executing raw SQL. So the scope is select-only vs. drop-the-schema? hows that enforced, string matching?
1
u/Inner_Storage_3374 1d ago
scoped api keys are the part i'd look at first, raw sql over http is a lot of power for a key that ends up in an edge function. can a key be limited to certain tables or to read only? that's what would make me trust it next to postgrest
1
u/Wooden-Jicama9825 1d ago
That scoped API key thing is doing a lot of work. PostgREST gets row-level security for free because each request runs as the role from the JWT, so if your gateway is just a pool of connections running as one role, every key you hand out has the same reach and RLS is decoration. Do you SET ROLE per request?
1
u/OldFuture7050 1d ago
Optional Redis integration in a Postgres-over-HTTP gateway is the part I keep staring at. What's actually living in there, the rate limit counters or cached query results?
1
u/Key-Resource-5898 1d ago
Small correction: HTTP is an application-layer protocol, not a transport layer. The transport layer is still TCP in both cases, so "another transport" or "another protocol" would be more accurate than "another transport layer".
1
u/Repulsive_Badger2634 20h ago
every self hosted project ends up with an optional Redis eventually. mine has one and honestly i could not tell you what it caches anymore
1
u/Unhappy-Tadpole2377 15h ago
everything gets a gateway now apparently