Initial commit of working RSS Aggregator build
This commit is contained in:
Vendored
+5
@@ -0,0 +1,5 @@
|
||||
import Parser from "rss-parser";
|
||||
const parser = new Parser();
|
||||
export default async function fetchFeed(url) {
|
||||
return parser.parseURL(url);
|
||||
}
|
||||
Vendored
+1
@@ -0,0 +1 @@
|
||||
export {};
|
||||
Vendored
+22
@@ -0,0 +1,22 @@
|
||||
import { prisma } from "../db.js";
|
||||
export default async function processEntries(feedId, parsed) {
|
||||
for (const item of parsed.items) {
|
||||
await prisma.entry.upsert({
|
||||
where: {
|
||||
guid_feedId: {
|
||||
guid: item.guid || item.link,
|
||||
feedId
|
||||
}
|
||||
},
|
||||
update: {},
|
||||
create: {
|
||||
feedId,
|
||||
guid: item.guid || item.link,
|
||||
title: item.title || "Untitled",
|
||||
link: item.link,
|
||||
content: item.contentSnippet || item.content || "",
|
||||
published: item.isoDate ? new Date(item.isoDate) : null
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user