-
Notifications
You must be signed in to change notification settings - Fork 120
Description
I’m really new to Inngest, so maybe this issue is totally unnecessary, sorry. I was planning to start testing inngest/agent-kit, but I couldn’t find an Express.js integration. It seems like it only supports creating a separate server on another port. That probably won’t work on Heroku (only one port allowed). So I investigated and will try this solution:
import { Inngest, slugify } from 'inngest';
import { serve } from 'inngest/express';
import { agents } from './agents';
import { networks } from './networks';
const inngest = new Inngest({ id: 'agent-kit' });
// Convert agents to Inngest functions (same logic as createServer)
const functions = [
...agents.map(agent => inngest.createFunction(
{ id: agent-${slugify(agent.name)}, name: agent.name, optimizeParallelism: true },
{ event: ${inngest.id}/agent-${slugify(agent.name)} },
async ({ event }) => agent.run(event.data.input)
)),
...networks.map(network => inngest.createFunction(
{ id: network-${slugify(network.name)}, name: network.name, optimizeParallelism: true },
{ event: ${inngest.id}/network-${slugify(network.name)} },
async ({ event }) => network.run(event.data.input)
))
];
// Mount as Express middleware (no separate port needed!)
app.use('/api/inngest', serve({ client: inngest, functions }));