postrust-worker
Postrust's REST API in a Cloudflare Worker, reaching PostgreSQL through Hyperdrive.
- The request pipeline is
postrust-engine, the same one the server runs. The database driver speaks the PostgreSQL wire protocol over a Workers socket and is tested to answer exactly as the server's does. - Every request runs in a transaction that takes on the token's role and claims, so row-level security applies as it does on the server.
- The schema cache is kept in Workers KV. It is refreshed by a Cron Trigger,
by an authenticated
POST /_/reload, or when the KV copy expires afterPGRST_WORKER_SCHEMA_TTL. - REST only, served at the root as PostgREST serves it. There is no GraphQL
and no
LISTEN/NOTIFY.
Setup, configuration, measured costs and limits:
docs/workers.md.
The crate is built with worker-build for wasm32-unknown-unknown; for any
other target it is only its configuration logic, there to be unit-tested.
This crate is on its own 0.x line and makes no stability promise yet. See
docs/stability.md.
Part of Postrust
Postrust turns a PostgreSQL database into a REST and GraphQL API. It is published as a set of crates so you can depend on only the part you need:
| Crate | Role | Docs |
|---|---|---|
postrust-server |
HTTP server | docs.rs |
postrust-core |
Engine | docs.rs |
postrust-sql |
SQL builder | docs.rs |
postrust-auth |
Authentication | docs.rs |
postrust-response |
Response formatting | docs.rs |
postrust-graphql |
GraphQL | docs.rs |
postrust-lambda |
AWS Lambda | docs.rs |
postrust-engine |
REST request pipeline | docs.rs |
postrust-worker (this crate) |
Cloudflare Workers | docs.rs |
postrust-proxy |
Reverse proxy | docs.rs |
Links
- Website: https://postrust.org/
- Documentation: https://postrust.org/docs
- Repository: https://github.com/postrust/postrust
- API docs for this crate: https://docs.rs/postrust-worker
License
MIT -- see LICENSE.