HTTP trigger
Custom API endpoints, one function each
Sometimes you just need an endpoint: enrich a lead, convert a currency, transform a JSON payload. With hostfunc each endpoint is one function with a stable URL — and because functions compose, a handful of them becomes a small backend.
The problem
Spinning up a framework, routing, and a deploy pipeline for a single JSON endpoint is heavy. But scattering one-off endpoints across providers makes them impossible to observe or reuse.
How hostfunc solves it
- Each endpoint is a single function with typed input and a stable run URL.
- Call other functions with fn.executeFunction to build composite APIs — depth-tracked and recorded.
- Store API keys as encrypted secrets and share them across the org via connectors.
- One observability pipeline across every endpoint: CPU, wall, memory, egress, per call.
convert.ts
import { secret } from "@hostfunc/sdk";
// GET/POST endpoint: { "from": "USD", "to": "EUR", "amount": 100 }
export async function main(input: { from: string; to: string; amount: number }) {
const apiKey = await secret.getRequired("FX_API_KEY");
const rates = await fetch(
`https://api.example.com/latest?base=${input.from}&apikey=${apiKey}`,
).then((r) => r.json());
const rate = rates[input.to];
return { from: input.from, to: input.to, amount: input.amount, result: input.amount * rate };
}