@miniappfy/functions
v0.2.0
Published
Types for MiniAppfy serverless functions (the server-side `ctx` + handler).
Readme
@miniappfy/functions
Types for MiniAppfy serverless functions — the server-side ctx and the handler signature.
Types only (the platform runs your function in an isolated sandbox).
import { defineHandler } from "@miniappfy/functions";
// src/functions/hello.ts
export default defineHandler(async (req, ctx) => {
await ctx.data.app.collection("notes").put("n1", { text: "hi" });
const note = await ctx.data.app.collection("notes").get("n1");
return new Response(JSON.stringify({ note }), {
headers: { "content-type": "application/json" },
});
});Declare the function and its trigger in manifest.json:
{
"functions": {
"hello": { "entry": "src/functions/hello.ts", "trigger": { "http": true } }
}
}Triggers: { "http": true } · { "event": "data.app.notes.*" } · { "cron": "*/5 * * * *" }.
Scaffold and test from the CLI:
miniapp functions new hello # interactive: name + trigger
miniapp functions test hello # run locally against your real app data
miniapp functions list
miniapp functions logs helloSee the functions guide.
