Technical reference for compiler configurations, global runtime variables, and standard APIs supported by the DataVec JavaScript-to-C compilation layer.
| 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> |
| scheduled(event, env) | async function | Cron-triggered entrypoint for recurring background work, on the same env bindings as fetch. | 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.websocket | WebSocket | Incoming WebSocket stream connection instance for real-time bi-directional messaging. |
Example endpoint streaming over a WebSocket and querying env.SQL by named prepared statement inside an isolated sandbox:
export default {
async fetch(request, env) {
if (request.headers.get('Upgrade') === 'websocket') {
const [client, server] = new WebSocketPair();
server.accept();
server.addEventListener('message', async (event) => {
// env.SQL.exec(statementName, binds) -> array of row objects
const users = await env.SQL.exec('active_users', [event.data]);
server.send(JSON.stringify(users));
});
return new Response(null, { status: 101, webSocket: client });
}
return new Response("Not a WebSocket connection", { status: 400 });
}
};