19 lines
583 B
JavaScript
19 lines
583 B
JavaScript
import { Worker } from "bullmq";
|
|
import { prisma } from "./db.js";
|
|
import fetchFeed from "./rss/fetchFeed.js";
|
|
import processEntries from "./rss/processEntries.js";
|
|
// BullMQ v4 requires host + port, NOT url
|
|
const connection = {
|
|
host: "redis",
|
|
port: 6379
|
|
};
|
|
new Worker("feeds", async (job) => {
|
|
const feedId = job.data.feedId;
|
|
const feed = await prisma.feed.findUnique({ where: { id: feedId } });
|
|
if (!feed)
|
|
return;
|
|
const parsed = await fetchFeed(feed.url);
|
|
await processEntries(feedId, parsed);
|
|
}, { connection });
|
|
console.log("Worker running");
|