Functions
Esta página aún no está disponible en tu idioma.
Trusted project code in a time-boxed process. → Functions and secrets
export default async function handler(req) { return { status: 200, body: { hello: req.body?.name ?? "world" } };}Functions → give it a name, edit the source, Deploy. Then Invoke with a JSON body; the result panel says function answered 200 … for the function’s own answer or cloud answered 5xx … for a Cloud error (timeout, bad output, missing runtime).
hcloud fn deploy prj_… hello ./hello.jshcloud fn list prj_…hcloud fn invoke prj_… hello '{"name": "cli"}' # status on stderr, body on stdouthcloud fn rm prj_… hellocurl -X PUT $ORIGIN/v0/projects/$PRJ/functions/hello -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: text/javascript' --data-binary @hello.jscurl -X POST $ORIGIN/v0/projects/$PRJ/functions/hello/invoke -H "Authorization: Bearer $TOKEN" \ -H 'Content-Type: application/json' -d '{"name":"curl"}' -i# the function's own answer carries an X-Hyphae-Function headerawait cloud.functions.deploy(project.id, "hello", source);const res = await cloud.functions.invoke(project.id, "hello", { name: "app" }); // the function's own answer// from an application, with a project key:const data = cloud.data(project.id, { key });await data.invoke("hello", { name: "app" });Names: a-z 0-9 _, up to 40 characters. Source ≤ 512 KiB; invoke body ≤ 32 KiB; 5 s timeout; two concurrent invocations per project. A function never receives a project key: pass one in the invoke body if it must reach Native.