@vercel/queue 0.0.0-alpha.37 → 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/README.md +208 -168
- package/dist/{types-CAA8nT8x.d.mts → callback-lq_sorrn.d.mts} +249 -16
- package/dist/{types-CAA8nT8x.d.ts → callback-lq_sorrn.d.ts} +249 -16
- package/dist/index.d.mts +74 -333
- package/dist/index.d.ts +74 -333
- package/dist/index.js +713 -679
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +709 -678
- package/dist/index.mjs.map +1 -1
- package/dist/nextjs-pages.d.mts +47 -27
- package/dist/nextjs-pages.d.ts +47 -27
- package/dist/nextjs-pages.js +320 -313
- package/dist/nextjs-pages.js.map +1 -1
- package/dist/nextjs-pages.mjs +320 -313
- package/dist/nextjs-pages.mjs.map +1 -1
- package/dist/web.d.mts +60 -0
- package/dist/web.d.ts +60 -0
- package/dist/web.js +1457 -0
- package/dist/web.js.map +1 -0
- package/dist/web.mjs +1420 -0
- package/dist/web.mjs.map +1 -0
- package/package.json +11 -1
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 };
|