MCPcopy Create free account
hub / github.com/boringstack-xyz/boringstack / setupQueues

Function setupQueues

apps/api/src/config/setup/setup-queues.ts:19–70  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

17 env.WEB_PUSH_VAPID_SUBJECT !== "";
18
19export const setupQueues = async (): Promise<QueueManager> => {
20 if (queueManager !== null) {
21 return queueManager;
22 }
23
24 const [
25 accountMaintenance,
26 emailDelivery,
27 notificationDispatch,
28 notificationMaintenance,
29 ] = await Promise.all([
30 setupAccountMaintenanceQueue(),
31 setupEmailDeliveryQueue(),
32 setupNotificationDispatchQueue(),
33 setupNotificationMaintenanceQueue(),
34 ]);
35
36 const webPushDelivery = isWebPushConfigured()
37 ? await setupWebPushDeliveryQueue()
38 : null;
39
40 queueManager = new QueueManager({
41 accountMaintenanceQueue: accountMaintenance.queue,
42 accountMaintenanceWorker: accountMaintenance.worker,
43 emailDeliveryQueue: emailDelivery.queue,
44 emailDeliveryWorker: emailDelivery.worker,
45 notificationDispatchQueue: notificationDispatch.queue,
46 notificationDispatchWorker: notificationDispatch.worker,
47 notificationMaintenanceQueue: notificationMaintenance.queue,
48 notificationMaintenanceWorker: notificationMaintenance.worker,
49 webPushDeliveryQueue: webPushDelivery?.queue ?? null,
50 webPushDeliveryWorker: webPushDelivery?.worker ?? null,
51 });
52
53 const initialized = [
54 "account-maintenance",
55 "email-delivery",
56 "notification-dispatch",
57 "notification-maintenance",
58 ];
59
60 if (webPushDelivery !== null) {
61 initialized.push("web-push-delivery");
62 }
63
64 logger.info("✅ Queues initialized", {
65 event: "queues_initialized",
66 queues: initialized,
67 });
68
69 return queueManager;
70};
71
72/**
73 * Returns the active QueueManager when queues are enabled, otherwise null.

Callers 1

index.tsFile · 0.90

Calls 7

setupEmailDeliveryQueueFunction · 0.90
infoMethod · 0.80
isWebPushConfiguredFunction · 0.70

Tested by

no test coverage detected