API
proxyShape
Serve an Electric shape from a route.
import { proxyShape } from '@wervt/nuxt/server'
export default defineEventHandler((event) =>
proxyShape(event, { table: 'todos', where: 'done = $1', params: [false] }),
)
| Option | Type | |
|---|---|---|
table | string | Table name without schema. |
where | string | SQL filter with $1, $2, … placeholders. |
params | (string | number | boolean)[] | Values for the placeholders. |
columns | string[] | Only sync these columns. Must include the primary key. |
Forwards Electric's protocol parameters (offset, handle, live, cursor, …) from the client and
returns Electric's response as a streaming Response.
In production the request goes through the runtime's
Electric gateway with the app's token. In nuxt dev
it goes to Electric directly with the schema-qualified table.
Do your auth checks before calling
proxyShape. Anyone who can call the route can read the shape.