UNPKG

@codecompose/typed-pubsub

Version:

A type-safe pub/sub abstraction for Google Cloud and Firebase

18 lines 1.19 kB
import { onMessagePublished as firebaseOnMessagePublished } from "firebase-functions/v2/pubsub"; import type { EventMarkingFunctions, HandlerOptions, PubsubTopicPayload, SchemaRecord } from "./types"; /** * Creates a factory function for generating type-safe Pubsub handlers * * @param schemas - Zod schemas for each topic * @param region - GCP region * @param eventMarkingFunctions - Optional functions for tracking processed * events * @param defaultOptions - Default options for all handlers * @returns A factory function for creating handlers */ export declare function createHandlerFactory<Schemas extends SchemaRecord<string>>(schemas: Schemas, region: string, eventMarkingFunctions?: EventMarkingFunctions, defaultOptions?: HandlerOptions, onMessagePublished?: typeof firebaseOnMessagePublished): <T extends keyof Schemas & string>({ topic, handler, options, }: { topic: T; handler: (payload: PubsubTopicPayload<Schemas, T>) => Promise<void>; options?: HandlerOptions; }) => import("firebase-functions").CloudFunction<import("firebase-functions").CloudEvent<import("firebase-functions/pubsub").MessagePublishedData<any>>>; //# sourceMappingURL=handler.d.ts.map