The entrypoints, bindings and standard objects a DataVec Worker can use.
| Name / Binding | Type | Description | Returns |
|---|---|---|---|
| fetch(request, env) | async function | The request entrypoint for a Worker. Receives the incoming request and bound environments. | Promise<Response> |
| websocket(ws, env) | async function | The WebSocket entrypoint, entered after the upgrade. for await (const msg of ws) reads each message; await ws.send(data) and await ws.close() reply. | Promise<void> |
| env.DB | binding | Embedded SQLite via the Cloudflare-D1 API — prepare(sql).bind(...).first() / .all() / .run(). In-process, no per-request reconnect. | D1Database |
| env.SQL | binding | Managed database over the PostgreSQL wire protocol from an isolated sandbox, via named prepared statements — exec(name, binds) resolves to an array of row objects. | SqlClient |
| env.BUCKET | binding | S3/R2-compatible object storage (key → bytes) — get, put, list, and delete blobs from a Worker. | ObjectStore |
| env.CONVERSATION | binding | Live model-token streaming (the AI-gateway shape) — stream(url, prompt) resolves to a readable token stream. | TokenStream |
| crypto.subtle | global | Standard Web Crypto (SubtleCrypto) — digests, HMAC, AES-GCM/CTR/CBC, ECDSA, RSA, and Ed25519 — compiled to native code. | SubtleCrypto |
| Property | Type | Description |
|---|---|---|
| request.url | string | The full incoming HTTP request URL string. |
| request.method | string | HTTP request verb (GET, POST, PUT, DELETE, etc.). |
| request.headers | Headers | Map of HTTP request headers. |
| request.json() | Promise | Reads the request body and parses it as JSON. |
A WebSocket endpoint that answers each message by querying env.SQL through a named prepared statement:
export default {
async websocket(ws, env) {
for await (const msg of ws) {
// env.SQL.exec(statementName, binds) -> array of row objects
const users = await env.SQL.exec('active_users', [msg]);
await ws.send(JSON.stringify(users));
}
await ws.close();
}
};