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.
79 lines (78 loc) • 2.24 kB
TypeScript
import { Request } from 'express';
/**
* HTTP utility functions
*/
/**
* Extract IP address from Express request
*/
export declare function getClientIp(req: Request): string;
/**
* Check if request is from Google Cloud Tasks
*/
export declare function isCloudTasksRequest(req: Request): boolean;
/**
* Validate Cloud Tasks request headers
*/
export declare function validateCloudTasksHeaders(req: Request): {
valid: boolean;
taskName?: string;
queueName?: string;
errors: string[];
};
/**
* Get request body size in bytes
*/
export declare function getRequestBodySize(req: Request): number;
/**
* Check if request contains JSON
*/
export declare function isJsonRequest(req: Request): boolean;
/**
* Extract bearer token from Authorization header
*/
export declare function getBearerToken(req: Request): string | null;
/**
* Create standardized error response
*/
export declare function createErrorResponse(message: string, code?: string, details?: any): {
success: false;
error: {
message: string;
code?: string;
details?: any;
timestamp: string;
};
};
/**
* Create standardized success response
*/
export declare function createSuccessResponse<T = any>(data: T, message?: string): {
success: true;
data: T;
message?: string;
timestamp: string;
};
/**
* Parse query string parameters safely
*/
export declare function parseQueryParam(value: string | string[] | undefined, defaultValue?: string): string | undefined;
/**
* Parse numeric query parameter
*/
export declare function parseNumericQueryParam(value: string | string[] | undefined, defaultValue?: number, min?: number, max?: number): number | undefined;
/**
* Parse boolean query parameter
*/
export declare function parseBooleanQueryParam(value: string | string[] | undefined, defaultValue?: boolean): boolean | undefined;
/**
* Parse array query parameter
*/
export declare function parseArrayQueryParam(value: string | string[] | undefined, separator?: string): string[];
/**
* Sanitize file name for safe usage
*/
export declare function sanitizeFileName(fileName: string): string;
/**
* Generate unique request ID
*/
export declare function generateRequestId(): string;