Backends
Functions
Write, deploy and call functions that run next to your backend.
Write one
terminal
npx @pherwerz/cloud new function hellophz/functions/hello/index.ts
import type { FunctionHandler } from '@pherwerz/cloud/functions';
const handler: FunctionHandler = async (req, ctx) =>
Response.json({ hello: 'world' });
export default handler;Run it locally
terminal
npx @pherwerz/cloud serveRuns phz/functions with hot reload, with secrets from phz/.env.local. It
needs Deno or Docker.
Deploy and call it
terminal
npx @pherwerz/cloud deploy functions # every function that changedts
const { data, error } = await phz.functions.invoke('hello', {
body: { name: 'world' },
});rollback function <name> <version> makes an earlier version live again.
Secrets are set with phz secrets set NAME=value.