You can create APIs to initiate workflows, data processing jobs, or other automated processes.
import { Api } from "@514labs/moose-lib"; interface WorkflowParams { inputValue: string; priority?: string;} interface WorkflowResponse { workflowId: string; status: string;} const triggerApi = new Api<WorkflowParams, WorkflowResponse>( "trigger-workflow", async ({ inputValue, priority = "normal" }: WorkflowParams, { client }) => { // Trigger the workflow with input parameters const workflowExecution = await client.workflow.execute("data-processing", { inputValue, priority, triggeredAt: new Date().toISOString() } ); return { workflowId: workflowExecution.id, status: "started" }; }); export default triggerApi;Once deployed, you can trigger workflows via HTTP requests:
curl "http://localhost:4000/api/trigger-workflow?inputValue=process-user-data&priority=high"Response:
{ "workflowId": "workflow-12345", "status": "started"}import { Api } from "@514labs/moose-lib"; interface WorkflowParams { inputValue: string; priority?: string;} interface WorkflowResponse { workflowId: string; status: string;} const triggerApi = new Api<WorkflowParams, WorkflowResponse>( "trigger-workflow", async ({ inputValue, priority = "normal" }: WorkflowParams, { client }) => { // Trigger the workflow with input parameters const workflowExecution = await client.workflow.execute("data-processing", { inputValue, priority, triggeredAt: new Date().toISOString() } ); return { workflowId: workflowExecution.id, status: "started" }; }); export default triggerApi;