⚡️⚡️⚡️ Self-hosted collaborative bookmark manager to collect, read, annotate, and fully preserve what matters, all in one place.
TypeScript bookmarkbookmark-managercollaborationnextjsreact-nativeread-it-laterself-hostedtypescript
rss feeds
Isaac Wisedac6ec966c1a
diff --git a/package.json b/package.jsonindex 4a8eb6d0..33831f26 100644--- a/package.json+++ b/package.json@@ -37,6 +37,7 @@"@types/nodemailer": "^6.4.8","@types/react": "18.2.14","@types/react-dom": "18.2.7",+ "@types/rss": "^0.0.32","axios": "^1.5.1","bcrypt": "^5.1.0","bootstrap-icons": "^1.11.2",@@ -77,6 +78,7 @@"react-select": "^5.7.4","react-spinners": "^0.14.1","react-window": "^1.8.10",+ "rss": "^1.2.2","rss-parser": "^3.13.0","socks-proxy-agent": "^8.0.2","stripe": "^12.13.0",diff --git a/pages/api/v1/links/index.ts b/pages/api/v1/links/index.tsindex dc7a2173..4360add1 100644--- a/pages/api/v1/links/index.ts+++ b/pages/api/v1/links/index.ts@@ -61,6 +61,7 @@ export default async function links(req: NextApiRequest, res: NextApiResponse) {req.body.newData);+return res.status(updated.status).json({response: updated.response,});diff --git a/pages/api/v1/user/rss/index.ts b/pages/api/v1/user/rss/index.tsindex fadd99ca..7f4c0b65 100644--- a/pages/api/v1/user/rss/index.ts+++ b/pages/api/v1/user/rss/index.ts@@ -20,6 +20,9 @@ export default async function handler(},},},+ where: {+ ownerId: user.id,+ },});return res.status(200).json({ response });@@ -30,9 +33,8 @@ export default async function handler(if (!dataValidation.success) {return res.status(400).json({- response: `Error: ${- dataValidation.error.issues[0].message- } [${dataValidation.error.issues[0].path.join(", ")}]`,+ response: `Error: ${dataValidation.error.issues[0].message+ } [${dataValidation.error.issues[0].path.join(", ")}]`,});}diff --git a/pages/public/collections/[id].tsx b/pages/public/collections/[id]/index.tsxsimilarity index 100%rename from pages/public/collections/[id].tsxrename to pages/public/collections/[id]/index.tsxdiff --git a/pages/public/collections/[id]/rss.tsx b/pages/public/collections/[id]/rss.tsxnew file mode 100644index 00000000..00e8e2f7--- /dev/null+++ b/pages/public/collections/[id]/rss.tsx@@ -0,0 +1,66 @@+import React from 'react'+import { GetServerSideProps } from 'next'+import { prisma } from '@/lib/api/db'+import RSS from 'rss'++const RSSFeed: React.FC = () => null++export const getServerSideProps: GetServerSideProps = async ({ params, res, req }) => {+ const id = parseInt(params?.id as string, 10);+ if (isNaN(id)) {+ if (res) {+ res.statusCode = 404+ res.end()+ }+ return { props: {} }+ }++ const data = await prisma.collection.findUnique({+ where: {+ id: parseInt(params?.id as string),+ isPublic: true,+ },+ include: {+ links: true,+ }+ })++ if (!data) {+ res.statusCode = 404;+ res.end('Not Found');+ return { props: {} };+ }++ const host = req.headers.host;++ const siteUrl = `https://${host}/collection/${data.id}`;+ const feedUrl = `https://${host}/collections/${data.id}/rss`;++ const feed = new RSS({+ title: data.name,+ description: data.description,+ site_url: siteUrl,+ feed_url: feedUrl,+ })++ data.links.forEach((link) => {+ feed.item({+ title: link.name,+ description: link.description,+ url: link.url || '',+ date: link.createdAt,+ })+ })++ const xml = feed.xml({ indent: true });++ if (res) {+ res.setHeader('Content-Type', 'text/xml')+ res.write(xml)+ res.end()+ }++ return { props: {} }+}++export default RSSFeed\ No newline at end of filediff --git a/yarn.lock b/yarn.lockindex 4dba2268..3a75484a 100644--- a/yarn.lock+++ b/yarn.lock@@ -2106,6 +2106,11 @@"@types/scheduler" "*"csstype "^3.0.2"+"@types/rss@^0.0.32":+ version "0.0.32"+ resolved "https://registry.yarnpkg.com/@types/rss/-/rss-0.0.32.tgz#19de5179a8160455c2f46a7699391ebacd4853cc"+ integrity sha512-2oKNqKyUY4RSdvl5eZR1n2Q9yvw3XTe3mQHsFPn9alaNBxfPnbXBtGP8R0SV8pK1PrVnLul0zx7izbm5/gF5Qw==+"@types/scheduler@*":version "0.16.2"resolved "https://registry.yarnpkg.com/@types/scheduler/-/scheduler-0.16.2.tgz#1a62f89525723dde24ba1b01b092bf5df8ad4d39"@@ -4537,6 +4542,18 @@ [email protected]:resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==+mime-db@~1.25.0:+ version "1.25.0"+ resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.25.0.tgz#c18dbd7c73a5dbf6f44a024dc0d165a1e7b1c392"+ integrity sha512-5k547tI4Cy+Lddr/hdjNbBEWBwSl8EBc5aSdKvedav8DReADgWJzcYiktaRIw3GtGC1jjwldXtTzvqJZmtvC7w==++ version "2.1.13"+ resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.13.tgz#e07aaa9c6c6b9a7ca3012c69003ad25a39e92a88"+ integrity sha512-ryBDp1Z/6X90UvjUK3RksH0IBPM137T7cmg4OgD5wQBojlAiUwuok0QeELkim/72EtcYuNlmbkrcGuxj3Kl0YQ==+ dependencies:+ mime-db "~1.25.0"+mime-types@^2.0.1, mime-types@^2.1.12, mime-types@~2.1.19:version "2.1.35"resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"@@ -5560,6 +5577,14 @@ rss-parser@^3.13.0:entities "^2.0.3"xml2js "^0.5.0"+rss@^1.2.2:+ version "1.2.2"+ resolved "https://registry.yarnpkg.com/rss/-/rss-1.2.2.tgz#50a1698876138133a74f9a05d2bdc8db8d27a921"+ integrity sha512-xUhRTgslHeCBeHAqaWSbOYTydN2f0tAzNXvzh3stjz7QDhQMzdgHf3pfgNIngeytQflrFPfy6axHilTETr6gDg==+ dependencies:+ mime-types "2.1.13"+ xml "1.0.1"+run-parallel@^1.1.9:version "1.2.0"resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee"@@ -6482,6 +6507,11 @@ xml2js@^0.5.0:sax ">=0.6.0"xmlbuilder "~11.0.0"+ version "1.0.1"+ resolved "https://registry.yarnpkg.com/xml/-/xml-1.0.1.tgz#78ba72020029c5bc87b8a81a3cfcd74b4a2fc1e5"+ integrity sha512-huCv9IH9Tcf95zuYCsQraZtWnJvBtLVE0QHMOs8bWyZAFZNDcYjsPq1nEx8jKA9y+Beo9v+7OBPRisQTjinQMw==+xmlbuilder@~11.0.0:version "11.0.1"resolved "https://registry.yarnpkg.com/xmlbuilder/-/xmlbuilder-11.0.1.tgz#be9bae1c8a046e76b31127726347d0ad7002beb3"