Functions and routes
A Node 22 function exports a default request handler that returns a Response. Put its source and config in the release manifest so it activates with the app’s routes and database changes. @run402/functions provides in-function helpers and editor types; Cloud bundles the platform’s installed helper package at deployment.
export default async function handler(req: Request): Promise<Response> { return Response.json({ message: "hello", method: req.method });}After adding the function to your manifest:
run402 up --checkrun402 up --project prj_examplerun402 functions invoke hello --project prj_example --method GETrun402 functions logs hello --project prj_exampleThe example assumes the function is named hello in the manifest. Direct function invocation and a public routed URL are different access paths. Declaring a route does not make every invocation endpoint anonymous. Configure route/function auth intentionally; do not mistake a public reachability warning for an authorization policy.
Schedules and event triggers can create durable function runs. Inspect fnrun_ and attempt handles, use stable idempotency keys where required, and distinguish queued work from a completed response. The function command reference covers list, logs, cancel and redrive. The function-runs example shows a complete fixture.
Read the result and recover
Section titled “Read the result and recover”Invocation prints the function response; logs are a separate operation. An authorization failure requires correcting the caller or declared gate, not removing authentication. A runtime failure requires the returned request ID and application logs. If deployment fails, inspect its stage before invoking: uploading code alone is not evidence of activation. Use run402 functions invoke --help for request-body file options and keep secrets out of arguments.