import { QueueOptions, Queue } from "bull"; import { bind, BindingScope, BindingTemplate, ContextTags, TagMap } from "@loopback/core"; import { BullQueueComponentBindings, BullQueueComponentTags } from "./keys"; /** * Interface defining the component's options object */ export interface BullQueueComponentOptions extends QueueOptions {} /** * Default options for the component */ export const DEFAULT_QUEUE_BULL_COMPONENT_OPTIONS: BullQueueComponentOptions = { // Specify the values here }; export type QueueConsumerOptions = { name: string; filterTags: TagMap } export function asBullQueueConsumer(options?: QueueConsumerOptions): BindingTemplate { let tags: TagMap = { [BullQueueComponentBindings.BULL_QUEUE_TYPE.key]: BullQueueComponentTags.QUEUE_TYPE_CONSUMER, } if(options?.filterTags) { tags.filterTags = options.filterTags } return binding => { binding .tag(tags) .inScope(BindingScope.TRANSIENT) .lock(); }; } export type SeawaspQueue = Queue;