···11# `@lure/express`
2233-Provides an Express-compatible middleware function for handling webhook
44-requests.
33+Provides an Express-compatible middleware function for processing webhook
44+events with Lure.
55+66+## Usage
77+88+```ts
99+import express from 'express';
1010+import { createLureHandler } from '@lure/express';
1111+1212+const app = express();
1313+1414+app.use(createLureHandler({
1515+ basePath: '/webhooks',
1616+ luresDir: './lures',
1717+ callback: async (prompt, config) => {
1818+ // Send the prompt to your LLM of choice
1919+ },
2020+}));
2121+```
2222+2323+The middleware calls `next()` for any request that does not match a lure path,
2424+so it can be composed freely with other Express middleware and routes.
2525+2626+### With config schema
2727+2828+```ts
2929+import express from 'express';
3030+import { createLureHandler } from '@lure/express';
3131+import * as v from 'valibot';
3232+3333+const app = express();
3434+3535+app.use(createLureHandler({
3636+ basePath: '/webhooks',
3737+ luresDir: './lures',
3838+ configSchema: v.object({
3939+ channel: v.string(),
4040+ }),
4141+ callback: async (prompt, config) => {
4242+ await notify(config.channel, prompt);
4343+ },
4444+}));
4545+```
4646+4747+### Options
4848+4949+| Option | Type | Default | Description |
5050+|---|---|---|---|
5151+| `basePath` | `string` | — | URL path prefix for all lure endpoints |
5252+| `luresDir` | `string` | — | Path to the directory containing `.lure` files |
5353+| `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 |
5454+| `configSchema` | Standard Schema | — | Schema for validating the `config` frontmatter block. Informs the type of `config` in `callback` |
5555+| `maxAttempts` | `number` | `1` | Number of times to attempt `callback` before dropping the webhook |
5656+| `allowUnverified` | `boolean` | `true` | Whether to allow `.lure` files without a `verify` block |
5757+| `watch` | `boolean` | `false` | Watch `luresDir` for changes and reload lures automatically |
+57-2
packages/fetch/README.md
···11# `@lure/fetch`
2233-Provides a fetch-compatible `Request -> Response` function for handling
44-webhooks.
33+Provides a fetch-compatible request handler for processing webhook events with
44+Lure. Suitable for use with Deno, Bun, Cloudflare Workers, or any other
55+runtime that uses the fetch API.
66+77+## Usage
88+99+```ts
1010+import { createLureHandler } from '@lure/fetch';
1111+1212+const lure = createLureHandler({
1313+ basePath: '/webhooks',
1414+ luresDir: './lures',
1515+ callback: async (prompt, config) => {
1616+ // Send the prompt to your LLM of choice
1717+ },
1818+});
1919+2020+Deno.serve((req) => lure(req) ?? new Response(null, { status: 404 }));
2121+```
2222+2323+`createLureHandler` returns `(req: Request) => Response | null`. A `null`
2424+return means the request path did not match any lure, leaving the caller free
2525+to handle it as appropriate.
2626+2727+### With config schema
2828+2929+Pass a [Standard Schema](https://standardschema.dev)-compatible schema to
3030+validate the `config` block in your `.lure` files. Any schema library that
3131+implements the Standard Schema spec (Zod, Valibot, Arktype, etc.) will work.
3232+3333+```ts
3434+import { createLureHandler } from '@lure/fetch';
3535+import * as v from 'valibot';
3636+3737+const lure = createLureHandler({
3838+ basePath: '/webhooks',
3939+ luresDir: './lures',
4040+ configSchema: v.object({
4141+ channel: v.string(),
4242+ }),
4343+ callback: async (prompt, config) => {
4444+ await notify(config.channel, prompt);
4545+ },
4646+});
4747+```
4848+4949+### Options
5050+5151+| Option | Type | Default | Description |
5252+|---|---|---|---|
5353+| `basePath` | `string` | — | URL path prefix for all lure endpoints |
5454+| `luresDir` | `string` | — | Path to the directory containing `.lure` files |
5555+| `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 |
5656+| `configSchema` | Standard Schema | — | Schema for validating the `config` frontmatter block. Informs the type of `config` in `callback` |
5757+| `maxAttempts` | `number` | `1` | Number of times to attempt `callback` before dropping the webhook |
5858+| `allowUnverified` | `boolean` | `true` | Whether to allow `.lure` files without a `verify` block |
5959+| `watch` | `boolean` | `false` | Watch `luresDir` for changes and reload lures automatically |