Skip to content

Run JavaScript

A JavaScript invocation runs against one selected disk on a Linux server. Its source is an async function body: use await and return directly. Each invocation starts with a fresh JS heap.

Execute JavaScript
curl --fail-with-body --no-buffer \
"https://api.wabe.sh/v1/disks/demo/exec?kind=js" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
--data-binary @- <<'JS'
await fs.mkdir('/notes', {recursive:true});
await fs.writeFile('/notes/hello.txt', 'Hello wabe Disk\n');
const app = kv.namespace('app');
await app.put('lastFile', '/notes/hello.txt');
print('saved');
return {path: await app.get('lastFile')};
JS

The response streams stdout/stderr records, a JSON result record on success, and a final exit record. Execution response defines their format.

Upload a script as a file, then invoke its virtual path:

Upload and execute a stored script
curl --fail-with-body -X PUT "https://api.wabe.sh/v1/disks/demo/files/app.js" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY" \
--data-binary @./app.js
curl --fail-with-body --no-buffer -X POST \
"https://api.wabe.sh/v1/disks/demo/exec?kind=js&path=/app.js" \
-H "Authorization: Bearer YOUR_PROJECT_API_KEY"

The selected script and all its file/KV calls use the same disk. The request body is available through io.stdin when the script comes from path or script in the query.

wabe Disk shell commands
qjs /app.js first second
qjs -e 'print(args[0])' hello
qjs - <<'JS'
print('Hello from stdin');
JS

args contains the arguments after the script selector. qjs - consumes stdin as source; use a stored path or -e when the script also needs stdin data. A returned value is emitted by direct HTTP JS execution. Shell qjs exposes printed stdout/stderr and an exit status.

Use fs for files, kv for typed state, and io, print and bash for streams and pipelines.

The runtime provides JavaScript built-ins and the documented wabe Disk globals. Node.js modules, package imports, network access, timers and native process APIs are unavailable. Scripts and argument bytes share documented limits. A script error stops execution; writes already published remain visible.