UNPKG

appwrite-utils-cli

Version:

Appwrite Utility Functions to help with database management, data conversion, data import, migrations, and much more. Meant to be used as a CLI tool, I do not recommend installing this in frontend environments.

30 lines (24 loc) 932 B
import { Client } from "node-appwrite"; import { AppwriteContext, AppwriteContextSchema } from "./context.js"; export default async function (context: AppwriteContext) { const { req, res, log, error } = context; // Optional: Validate the context using Zod schema try { AppwriteContextSchema.parse(context); log("Context validation successful"); } catch (validationError) { error(`Context validation failed: ${validationError}`); } const client = new Client() .setEndpoint(process.env["APPWRITE_FUNCTION_ENDPOINT"]!) .setProject(process.env["APPWRITE_FUNCTION_PROJECT_ID"]!) .setKey(req.headers["x-appwrite-key"] || ""); log(`Processing ${req.method} request to ${req.path}`); return res.json({ message: "Hello from TypeScript function!", functionName: "{{functionName}}", method: req.method, path: req.path, headers: req.headers, }); }