@vercel/queue 0.0.0-alpha.39 → 0.0.0-alpha.40

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.
@@ -1,68 +0,0 @@
1
- import { M as MessageHandler, H as HandleCallbackOptions } from './callback-lq_sorrn.mjs';
2
-
3
- /**
4
- * Next.js Pages Router wrapper for queue callback handling.
5
- *
6
- * Provides a `handleCallback` that returns a standard Pages Router API
7
- * handler `(req, res) => Promise<void>`, compatible with `pages/api/` routes.
8
- *
9
- * @example
10
- * ```typescript
11
- * // pages/api/queue/my-topic.ts
12
- * import { handleCallback } from "@vercel/queue/nextjs/pages";
13
- *
14
- * export default handleCallback(async (message, metadata) => {
15
- * console.log("Processing:", message);
16
- * });
17
- * ```
18
- */
19
-
20
- /**
21
- * Minimal subset of Next.js `NextApiRequest` used by this wrapper.
22
- */
23
- interface NextApiRequest {
24
- method?: string;
25
- headers: Record<string, string | string[] | undefined>;
26
- body?: unknown;
27
- }
28
- /**
29
- * Minimal subset of Next.js `NextApiResponse` used by this wrapper.
30
- */
31
- interface NextApiResponse {
32
- status(statusCode: number): NextApiResponse;
33
- json(data: unknown): void;
34
- end(): void;
35
- }
36
- /**
37
- * Create a Next.js Pages Router API handler for processing queue callback messages.
38
- *
39
- * Parses `req.body` as a CloudEvent (Next.js auto-parses JSON bodies)
40
- * and invokes the message handler.
41
- * Non-POST requests are responded to with 200 OK (for health checks).
42
- *
43
- * Response status codes:
44
- * - **200** on success or non-POST requests
45
- * - **400** for invalid CloudEvent payloads
46
- * - **500** for unexpected processing errors
47
- *
48
- * @param handler - Function to process the message payload and metadata
49
- * @param options - Optional configuration
50
- * @param options.client - Custom QueueClient instance
51
- * @param options.visibilityTimeoutSeconds - Message lock duration (default: 300, max: 3600)
52
- * @returns A `(req, res) => Promise<void>` Pages Router API handler
53
- *
54
- * @example
55
- * ```typescript
56
- * import { handleCallback } from "@vercel/queue/nextjs/pages";
57
- *
58
- * export default handleCallback(
59
- * async (order, metadata) => {
60
- * await processOrder(order);
61
- * },
62
- * { visibilityTimeoutSeconds: 300 },
63
- * );
64
- * ```
65
- */
66
- declare function handleCallback<T = unknown>(handler: MessageHandler<T>, options?: HandleCallbackOptions): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
67
-
68
- export { handleCallback };
@@ -1,68 +0,0 @@
1
- import { M as MessageHandler, H as HandleCallbackOptions } from './callback-lq_sorrn.js';
2
-
3
- /**
4
- * Next.js Pages Router wrapper for queue callback handling.
5
- *
6
- * Provides a `handleCallback` that returns a standard Pages Router API
7
- * handler `(req, res) => Promise<void>`, compatible with `pages/api/` routes.
8
- *
9
- * @example
10
- * ```typescript
11
- * // pages/api/queue/my-topic.ts
12
- * import { handleCallback } from "@vercel/queue/nextjs/pages";
13
- *
14
- * export default handleCallback(async (message, metadata) => {
15
- * console.log("Processing:", message);
16
- * });
17
- * ```
18
- */
19
-
20
- /**
21
- * Minimal subset of Next.js `NextApiRequest` used by this wrapper.
22
- */
23
- interface NextApiRequest {
24
- method?: string;
25
- headers: Record<string, string | string[] | undefined>;
26
- body?: unknown;
27
- }
28
- /**
29
- * Minimal subset of Next.js `NextApiResponse` used by this wrapper.
30
- */
31
- interface NextApiResponse {
32
- status(statusCode: number): NextApiResponse;
33
- json(data: unknown): void;
34
- end(): void;
35
- }
36
- /**
37
- * Create a Next.js Pages Router API handler for processing queue callback messages.
38
- *
39
- * Parses `req.body` as a CloudEvent (Next.js auto-parses JSON bodies)
40
- * and invokes the message handler.
41
- * Non-POST requests are responded to with 200 OK (for health checks).
42
- *
43
- * Response status codes:
44
- * - **200** on success or non-POST requests
45
- * - **400** for invalid CloudEvent payloads
46
- * - **500** for unexpected processing errors
47
- *
48
- * @param handler - Function to process the message payload and metadata
49
- * @param options - Optional configuration
50
- * @param options.client - Custom QueueClient instance
51
- * @param options.visibilityTimeoutSeconds - Message lock duration (default: 300, max: 3600)
52
- * @returns A `(req, res) => Promise<void>` Pages Router API handler
53
- *
54
- * @example
55
- * ```typescript
56
- * import { handleCallback } from "@vercel/queue/nextjs/pages";
57
- *
58
- * export default handleCallback(
59
- * async (order, metadata) => {
60
- * await processOrder(order);
61
- * },
62
- * { visibilityTimeoutSeconds: 300 },
63
- * );
64
- * ```
65
- */
66
- declare function handleCallback<T = unknown>(handler: MessageHandler<T>, options?: HandleCallbackOptions): (req: NextApiRequest, res: NextApiResponse) => Promise<void>;
67
-
68
- export { handleCallback };