@vercel/queue 0.0.0-alpha.36 → 0.0.0-alpha.38

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/web.d.ts ADDED
@@ -0,0 +1,60 @@
1
+ import { M as MessageHandler, H as HandleCallbackOptions } from './callback-lq_sorrn.js';
2
+
3
+ /**
4
+ * Web API (App Router / Hono) wrapper for queue callback handling.
5
+ *
6
+ * Provides a `handleCallback` that returns a standard `(Request) => Promise<Response>`
7
+ * handler, compatible with Next.js App Router route handlers, Hono, and any
8
+ * framework that uses the Web API `Request`/`Response` types.
9
+ *
10
+ * @example
11
+ * ```typescript
12
+ * // Next.js App Router — app/api/queue/route.ts
13
+ * import { handleCallback } from "@vercel/queue/web";
14
+ *
15
+ * export const POST = handleCallback(async (message, metadata) => {
16
+ * console.log("Processing:", message);
17
+ * });
18
+ * ```
19
+ *
20
+ * @example
21
+ * ```typescript
22
+ * // Hono
23
+ * import { Hono } from "hono";
24
+ * import { handleCallback } from "@vercel/queue/web";
25
+ *
26
+ * const app = new Hono();
27
+ * app.post("/api/queue", handleCallback(handler));
28
+ * ```
29
+ */
30
+
31
+ /**
32
+ * Create a Web API route handler for processing queue callback messages.
33
+ *
34
+ * Parses the incoming `Request` as a CloudEvent and invokes the message handler.
35
+ * Returns appropriate HTTP responses:
36
+ * - **200** on success
37
+ * - **400** for invalid CloudEvent payloads
38
+ * - **500** for unexpected processing errors
39
+ *
40
+ * @param handler - Function to process the message payload and metadata
41
+ * @param options - Optional configuration
42
+ * @param options.client - Custom QueueClient instance
43
+ * @param options.visibilityTimeoutSeconds - Message lock duration (default: 300, max: 3600)
44
+ * @returns A `(request: Request) => Promise<Response>` route handler
45
+ *
46
+ * @example
47
+ * ```typescript
48
+ * import { handleCallback } from "@vercel/queue/web";
49
+ *
50
+ * export const POST = handleCallback(
51
+ * async (order, metadata) => {
52
+ * await processOrder(order);
53
+ * },
54
+ * { visibilityTimeoutSeconds: 300 },
55
+ * );
56
+ * ```
57
+ */
58
+ declare function handleCallback<T = unknown>(handler: MessageHandler<T>, options?: HandleCallbackOptions): (request: Request) => Promise<Response>;
59
+
60
+ export { handleCallback };