{"flow":{"id":62,"summary":"HTTP flow with preprocessor template","versions":[224,225,232,233,244,270,274],"created_by":"dieriba.pro916","created_at":"2025-03-03T15:35:40.749Z","votes":0,"approved":true,"apps":["windmill"],"value":{"modules":[],"preprocessor_module":{"id":"preprocessor","value":{"tag":"","type":"rawscript","content":"/**\n * General Trigger Preprocessor\n *\n * ⚠️ This function runs BEFORE the main function.\n *\n * It processes raw trigger data (e.g., MQTT, HTTP, SQS, WebSocket, Kafka, NATS) before passing it to main().\n * Common tasks:\n * - Convert binary payloads to string/JSON (if applicable)\n * - Extract metadata\n * - Filter messages\n * - Add timestamps/context\n *\n * The returned object determines main() parameters:\n * - {a: 1, b: 2} → main(a, b)\n * - {http} → main(http)\n *\n * @param event - Trigger data (e.g., HTTP, WebSocket, Kafka, etc.)\n * @returns Processed data for main()\n */\nexport async function preprocessor(\n  event: {\n    kind: 'http';\n    body: any;\n    raw_string: string | null;\n    route: string;\n    path: string;\n    method: string;\n    params: Record<string, string>; // path params\n    query: Record<string, string>; // query params\n    headers: Record<string, string>;\n  }\n) {\n  if (event.kind === 'http') {\n    return {\n      body: event.body,\n      params: event.params,\n      query: event.query,\n    };\n  }\n\n  throw new Error(`Expected http trigger kind, got: ${event.kind}`);\n}\n","language":"bun","input_transforms":{"event":{"type":"static"}}}}},"schema":{"type":"object","order":["body","params","query"],"$schema":"https://json-schema.org/draft/2020-12/schema","required":["body","params","query"],"properties":{"body":{"type":"object","nullable":false,"description":"HTTP request body"},"query":{"type":"object","nullable":false,"description":"Query parameters from the HTTP request"},"params":{"type":"object","nullable":false,"description":"Path parameters from the HTTP request"}}},"description":"","recording":null,"vcreated_at":"2025-05-16T08:27:43.156Z","vcreated_by":"hugo697","comments":[]}}