Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
import { Worker, type Job } from 'bullmq';
|
2026-05-06 14:58:34 +02:00
|
|
|
import { env } from '@/lib/env';
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
|
|
|
|
|
import type { ConnectionOptions } from 'bullmq';
|
|
|
|
|
import { logger } from '@/lib/logger';
|
|
|
|
|
import { QUEUE_CONFIGS } from '@/lib/queue';
|
|
|
|
|
|
2026-05-06 14:58:34 +02:00
|
|
|
/**
|
|
|
|
|
* v1 of bulk operations runs synchronously through per-entity bulk
|
|
|
|
|
* endpoints (see `/api/v1/interests/bulk`) — a per-row loop, capped at
|
|
|
|
|
* the page size (100). The synchronous path gives the user instant
|
|
|
|
|
* feedback and a per-row failure list, which the queue can't.
|
|
|
|
|
*
|
|
|
|
|
* This worker remains here for genuinely-async cases (CSV imports,
|
|
|
|
|
* port-wide migrations, bulk emails to >100 recipients) where the
|
|
|
|
|
* caller polls for completion. Currently no producer enqueues to this
|
|
|
|
|
* queue — add producers as those use cases surface.
|
|
|
|
|
*/
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
export const bulkWorker = new Worker(
|
|
|
|
|
'bulk',
|
|
|
|
|
async (job: Job) => {
|
|
|
|
|
logger.info({ jobId: job.id, jobName: job.name }, 'Processing bulk job');
|
|
|
|
|
},
|
|
|
|
|
{
|
2026-05-06 14:58:34 +02:00
|
|
|
connection: { url: env.REDIS_URL } as ConnectionOptions,
|
Initial commit: Port Nimara CRM (Layers 0-4)
Full CRM rebuild with Next.js 15, TypeScript, Tailwind, Drizzle ORM,
PostgreSQL, Redis, BullMQ, MinIO, and Socket.io. Includes 461 source
files covering clients, berths, interests/pipeline, documents/EOI,
expenses/invoices, email, notifications, dashboard, admin, and
client portal. CI/CD via Gitea Actions with Docker builds.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-03-26 11:52:51 +01:00
|
|
|
concurrency: QUEUE_CONFIGS.bulk.concurrency,
|
|
|
|
|
},
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
bulkWorker.on('failed', (job, err) => {
|
|
|
|
|
logger.error({ jobId: job?.id, jobName: job?.name, err }, 'Bulk job failed');
|
|
|
|
|
});
|