UNPKG

nodejs-cloud-taskmq

Version:

Node.js TypeScript library for integrating Google Cloud Tasks with MongoDB/Redis/Memory/Custom for a BullMQ-like queue system. Compatible with NestJS but framework-agnostic.

57 lines (56 loc) 1.34 kB
import 'reflect-metadata'; /** * Metadata key for cloud task consumer decorators */ export declare const CLOUD_TASK_CONSUMER_KEY = "cloud_taskmq:cloud_task_consumer"; /** * CloudTask consumer options */ export interface CloudTaskConsumerOptions { /** * Queue name to consume tasks from */ queueName: string; /** * HTTP endpoint path for receiving tasks */ path?: string; /** * HTTP method for the endpoint */ method?: 'POST' | 'GET' | 'PUT' | 'DELETE'; /** * Maximum concurrent tasks */ maxConcurrency?: number; /** * Task timeout in milliseconds */ timeout?: number; /** * Custom headers to validate */ headers?: Record<string, string>; } /** * Decorator for marking a class as a CloudTask consumer. * This decorator sets up HTTP endpoints for Google Cloud Tasks to call. * * @param options Consumer configuration options * * @example * ```typescript * @CloudTaskConsumer({ * queueName: 'email-queue', * path: '/tasks/email', * method: 'POST' * }) * export class EmailTaskConsumer { * async handleTask(taskData: any) { * // Process the task * return { success: true }; * } * } * ``` */ export declare function CloudTaskConsumer(options: CloudTaskConsumerOptions): (target: any) => void;