@lure-hooks/express
v1.0.0
Published
Express middleware adapter for Lure — process webhook events into LLM prompts
Downloads
12
Maintainers
Readme
@lure-hooks/express
Provides an Express-compatible middleware function for processing webhook events with Lure.
Installation
npm install @lure-hooks/expressUsage
import express from "express";
import { createLureHandler } from "@lure-hooks/express";
const app = express();
const lure = await createLureHandler({
basePath: "/webhooks",
luresDir: "./lures",
callback: async (prompt, config) => {
// Send the prompt to your LLM of choice
},
});
app.use(lure);The middleware calls next() for any request that does not match a lure path,
so it can be composed freely with other Express middleware and routes.
With config schema
import express from "express";
import { createLureHandler } from "@lure-hooks/express";
import * as v from "valibot";
const app = express();
const lure = await createLureHandler({
basePath: "/webhooks",
luresDir: "./lures",
configSchema: v.object({
channel: v.string(),
}),
callback: async (prompt, config) => {
await notify(config.channel, prompt);
},
});
app.use(lure);Options
| Option | Type | Default | Description |
| ----------------- | ---------------------------------------------------- | ------- | ---------------------------------------------------------------------------------------------------------------------------- |
| basePath | string | — | URL path prefix for all lure endpoints |
| luresDir | string | — | Path to the directory containing .lure files |
| callback | (prompt: string, config: TConfig) => Promise<void> | — | Called with the rendered prompt on each verified webhook. TConfig is inferred from configSchema, or unknown if omitted |
| configSchema | Standard Schema | — | Schema for validating the config frontmatter block. Informs the type of config in callback |
| maxAttempts | number | 1 | Number of times to attempt callback before dropping the webhook |
| allowUnverified | boolean | true | Whether to allow .lure files without a verify block |
| watch | boolean | false | Watch luresDir for changes and reload lures automatically |
